thread-expr

Thread-expr provides macros for use within a clojure threaded argument expression (->).

License

License

GroupId

GroupId

org.cloudhoist
ArtifactId

ArtifactId

thread-expr
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

thread-expr
Thread-expr provides macros for use within a clojure threaded argument expression (->).
Source Code Management

Source Code Management

https://github.com/pallet/thread-expr

Download thread-expr

How to add to project

<!-- https://jarcasting.com/artifacts/org.cloudhoist/thread-expr/ -->
<dependency>
    <groupId>org.cloudhoist</groupId>
    <artifactId>thread-expr</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.cloudhoist/thread-expr/
implementation 'org.cloudhoist:thread-expr:1.2.0'
// https://jarcasting.com/artifacts/org.cloudhoist/thread-expr/
implementation ("org.cloudhoist:thread-expr:1.2.0")
'org.cloudhoist:thread-expr:jar:1.2.0'
<dependency org="org.cloudhoist" name="thread-expr" rev="1.2.0">
  <artifact name="thread-expr" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.cloudhoist', module='thread-expr', version='1.2.0')
)
libraryDependencies += "org.cloudhoist" % "thread-expr" % "1.2.0"
[org.cloudhoist/thread-expr "1.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.clojure : clojure jar 1.2.1
org.clojure : tools.macro jar 0.1.1

Project Modules

There are no modules declared in this project.

pallet.thread-expr

A library containing macros for use in clojure threading expressions (using ->).

See reference documentation and annotated source.

Examples

Threaded arg exposure:

arg-> exposes the threaded arg, binding it to the supplied variable. For example:

(-> 2
   (arg-> [x]
     (* (inc x))))

;=> 6

Expands to:

(-> 2 
   ((fn [arg] (let [x arg] (-> arg (* inc x))))))

;=> 6

Note the extra set of parens in the expansion; the threading macro feeds the current argument in as arg, binds it to the supplied var using let, and resumes threading for all forms inside of arg->.

Threaded list comprehension:

The following use of for->:

(-> 1
   (for-> [x [1 2 3]]
     (+ x)))

;=> 7

Expands to:

(-> 1
   (+ 1)
   (+ 2)
   (+ 3))

;=> 7

Installation

thread-expr is distributed as a jar, and is available in the clojars repository.

Installation is with leiningen or your favourite maven repository aware build tool.

lein/cake project.clj

:dependencies [[com.palletops/thread-expr "1.3.0"]]

maven pom.xml

<dependencies>
  <dependency>
    <groupId>org.cloudhoist</groupId>
    <artifactId>thread-expr</artifactId>
    <version>1.3.0</version>
  </dependency>
<dependencies>

<repositories>
  <repository>
    <id>clojars</id>
    <url>http://clojars.org/repo</url>
  </repository>
</repositories>

License

Licensed under EPL

Copyright 2011, 2012, 2013 Hugo Duncan.

org.cloudhoist

pallet

Versions

Version
1.2.0
1.1.0
1.0.0