Core Library Essentials
YAMLScript has a very large set of useful functions that it inherits from Clojure's clojure.core
library.
These functions are the bread and butter building blocks of YAMLScript programming.
The functions are very well organized in the Clojure Docs Quick Reference and you can get to the documentation for each function from there.
This document is a condensed quick reference of the functions that are most commonly used in YAMLScript programming.
YAMLScript also has the ys::std
standard library that provides additional functions.
The YAMLScript standard library replaces some Clojure functions with a version more suited to YAMLScript. In those cases, the original Clojure function is still available in the ys::clj
namespace.
Number
Arithmetic
Clojure Core:
YAMLScript Std:
%
,%%
infix operatorsadd
,sub
,mul
,div
named math functionssum
,sqr
,cube
,sqrt
,pow
,abs
add+
,sub+
,mul+
,div+
polymorphic functions
See Also:
clojure.math
functions callable asmath/<func-name>
in YAMLScript.
Comparison
Clojure Core:
YAMLScript Std:
==
,!=
infix operatorseq
,ne
,lt
,gt
,le
,ge
named comparison functions
Cast
Clojure Core:
YAMLScript Std:
to-num
,to-int
,to-float
- polymorphic cast functions
Test
Clojure Core:
Boolean
Clojure Core:
YAMLScript Std:
truey?
,falsey?
,to-bool
,to-booly
String
Clojure Core:
YAMLScript Std:
words
,split
,join
,lines
,text
,replace
,replace1
chomp
,trim
,triml
,trimr
,lc
,uc
,uc1
,index
,pretty
See Also:
clojure.string
functions callable asstr/<func-name>
in YAMLScript.
Regular Expression
Clojure Core:
YAMLScript Std:
=~
,!~
infix operators/.../
regex literalsqr
Flow Control
Boolean
Clojure Core:
YAMLScript Std:
||
,&&
,|||
,&&&
infix operatorsor?
,and?
booly named functions
Normal
Clojure Core:
- if, when, if-not, when-not, if-let, when-let, if-some, when-some, cond, condp, case, do, eval, loop, recur, while
YAMLScript Std:
if-lets
,when-lets
,call
,each
,exit
,sleep
Exception
Clojure Core:
YAMLScript Std:
die
,warn
,exit
,err
Function
Clojure Core:
YAMLScript Std:
\(...)
anonymous function syntax.
dot chaining infix operatorvalue
,call
Collection
General
Clojure Core:
- count, empty, not-empty, into, conj, contains?, distinct?, empty?, every?, some, not-every?, not-any?, coll?, seq?, vector?, list?, map?, set?, sorted?, sequential?, associative?
YAMLScript Std:
grep
,has?
,in?
Vector
Clojure Core:
List
Clojure Core:
Map
Clojure Core:
- hash-map, array-map, sorted-map, zipmap, frequencies, assoc, assoc-in, dissoc, find, get-in, update-in, key, val, keys, vals, merge, reduce-kv
YAMLScript Std:
omap
,get+
Sequence
Clojure Core:
- seq, repeat, range, iterate, cycle, interleave, interpose, first, second, last, rest, next, butlast, nth, take, drop, take-while, drop-while, conj, concat, map, filter, remove, sort, shuffle, flatten, for, doseq, dorun, doall, mapcat, reduce, keep
YAMLScript Std:
..
infix rng operatorrng
,reverse
Variable
Clojure Core:
- def, intern, declare, binding, gensym, var, var-get, resolve, find-var, alter-var-root, var?, bound?
YAMLScript Std:
=:
,.=:
,+=:
,-=:
,*=:
,/=:
def/let syntaxvalue
I/O
Clojure Core:
- print, printf, println, pr, prn, print-str, println-str, pr-str, prn-str, newline, flush, slurp, spit, with-out-str, with-open, with-in-str
YAMLScript Std:
say
,out
,warn
,pp