Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ground

About

Build Status Clojars Project

"The ground wire is an additional path for electrical current to return safely to the ground without danger to anyone in the event of a short circuit."

ground

Getting Started

(ns demo.core
  (:require [ground.core :refer :all]))

Usage

The n-> and n->> threading macros allow for predicates and side effects within their forms.

n? predicates

n? signals a predicate that will pass through the result of the prior expression if true and return nil for the entire form if false

(n-> 6
     (n? (> 5))
     (vector 7 8)) => [6 7 8]

(n-> 9
     (n? (> 10))
     (vector 11 12)) => nil
(n->> [1 2 3]
      (n? (every? identity))
      (map inc)) => '(2 3 4)

(n->> [1 nil 3]
      (n? (every? identity))
      (map inc)) => nil

n! side effects

n! signals a side effect, such as printing or logging, that will always pass through the result of the prior expression

(n-> 4
     (n! (println "is the best number")) ;; prints "4 is the best number"
     inc) => 5	

(n->> ["right" "blue" "humpback"]
      (n! (apply println "These are different types of whales:")) ;; prints "These are different types of whales: right blue humpback"
      sort) => '("blue" "humpback" "right")

References

About

library of threading macros to handle predicates and side effects.

Resources

License

Releases

No releases published

Packages

No packages published