Liking cljdoc? Tell your friends :D

travis-ci.org

Examples tested with midje-readme

clojure.utils

A collection of Clojure utilities.

Usage

Leiningen coordinate:

[com.borkdal/clojure.utils "0.1.1"]

Examples

Checking for non-empty string

(non-empty-string? "yes") => true

(non-empty-string? :no) => false

(non-empty-string? nil) => false

Checking for substring

(substring? "cd" "abcdef") => true

(substring? "xxx" "abcdef") => false

Converting to int

(to-int "7") => 7

Checking not nil

(not-nil? 7) => true

(not-nil? nil) => false

Joining non-nil strings with spaces

(spaced-str "abc" nil 7 "ghi") => "abc 7 ghi"

when-let for non-empty sequences

(when-seq-let [seq nil]
  :yes) => nil

(when-seq-let [seq '()]
  :yes) => nil

(when-seq-let [seq '(1 2 3)]
  :yes) => :yes

first for strings that should have a single element

(fact "one-element sequence"
  (only [1]) => 1)

(fact "multi-element sequence"
  (only [1 2 3]) => (throws java.lang.AssertionError))

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close