rcullito.ground

https://github.com/rcullito/ground.git

git clone 'https://github.com/rcullito/ground.git'

(ql:quickload :rcullito.ground)
6

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