Clojure Core Essentials
YS 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 YS 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 YS programming.
YS also has the ys::std
standard library that provides
additional functions.
The YS standard library replaces some Clojure functions with a version
more suited to YS.
In those cases, the original Clojure function is still available in the
ys::clj
namespace.
Number🔗
Arithmetic🔗
Clojure Core:
YS 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 YS.
Comparison🔗
Clojure Core:
YS Std:
==
,!=
infix operatorseq
,ne
,lt
,gt
,le
,ge
named comparison functions
Cast🔗
Clojure Core:
YS Std:
to-num
,to-int
,to-float
- polymorphic cast functions
Test🔗
Clojure Core:
Boolean🔗
Clojure Core:
YS Std:
truey?
,falsey?
,to-bool
,to-booly
String🔗
Clojure Core:
YS 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 YS.
Regular Expression🔗
Clojure Core:
- re-pattern , re-matches , re-find , re-seq , re-groups
YS Std:
=~
,!~
infix operators/.../
regex literalsqr
Flow Control🔗
Boolean🔗
Clojure Core:
YS 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
YS Std:
if-lets
,when-lets
,call
,each
,exit
,sleep
Exception🔗
Clojure Core:
YS Std:
die
,warn
,exit
,err
Function🔗
Clojure Core:
- fn , defn , defn- , identity , comp , partial , complement , constantly , -> , ->> , apply , fn? , ifn?
YS 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?
YS 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
YS 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
YS Std:
..
infix rng operatorrng
,reverse
Variable🔗
Clojure Core:
- def , intern , declare , binding , gensym , var , var-get , resolve , find-var , alter-var-root , var? , bound?
YS 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
YS Std:
say
,out
,warn
,pp