Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tools to aid navigating deeply nested Clojure data structures from code or the REPL.

License

NotificationsYou must be signed in to change notification settings

fuse-code/clojure-navigation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  • Each appropriate command pretty-prints the first 20 rows of the current data structure.
  • Data structure listings are automatically paged so you're less likely to blow up your REPLby inadvertently listing a huge data structure.
  • At the same time, the current object pointed-to by the (pwd) is always available so you canmap, mapcat, reduce, and grep the actual objects to your heart's content.
    (mount data-structure)    (cd:child-node1:another-child ...)    (cd"..")    (ls)    (pwd)    (current); return the current object    (current:sub1:sub2 ...); return the object referenced by :sub1 and :sub2 from (current)

Duck-typed Grep for deeply recursively nested data structures.

Generally:

    (grep matcher root-object)

Recursively applies matcher toall children of root-object. When a match is found, the containerof the matched object is returned.

The matcher itself can be any type. If it is a regular expression Pattern, it is matched againststrings or the output of (.toString obj) Strings match any substring of (.toString object).All other objects match using (= matcher obj).

Example:

    => (grep :diffed (current))    [[:diffed {}] [:diffed {}]]

In this case, grep searched a data structure that reports differences between two related objects.This run determined that there were no differences found under (current).

A pipe operator that can map, mapcat, and reduce a collection in Unix-style.

    (| (range50) inc #(/ %2) +)

Behavior injection

(Experimental module)

Inject behavior before/after/around all forms in a do-style block or thread-lastmacro form (experimental).

For example:

    (inject logging (form1) (form2) ...)

Logs each form as it is executed. If a form takes longer than 1/2 second, logs the elapsedtime as well.

Or:

    (fns (form1) (form2) ...)

Returns a vector containing all forms converted into 0-arg functions. These functions thencan be executed during a map, mapcat, or reduce operation and their results stored, furtherprocessed, logged, etc.

Usage

These utilities are designed mainly to enhance REPL usage, so we suggest adding them to your.lein/profiles.clj in the :user or :dev profile or equivalent for your build tool.

Leiningen coordinates

One might always want these utilities available, even at runtime. In that case, addingthem to your :user profile would make sense. To do that, merge the following into your:user map in your profiles.clj file.

:user {:repositories [["jitpack""https://jitpack.io"]]:dependencies [[com.github.shopsmart/clojure-navigation"version"]]}

where "version" currently is "Release".

Maven coordinates

<repositories>  <repository>    <id>jitpack.io</id><name>Jitpack repo</name><url>https://jitpack.io</url>  </repository></repositories>
  • GroupId: com.github.shopsmart
  • ArtifactId: clojure-navigation
  • Version:Release

License

Copyright © 2015 by ShopSmart, LLC. Licensed under the Eclipse Public License v1.0.

Authors

David Orme

About

Tools to aid navigating deeply nested Clojure data structures from code or the REPL.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure100.0%

[8]ページ先頭

©2009-2025 Movatter.jp