iterates over array
, evaluating body
once for each value in
array
. If item
is a literal name, that will be the variable into
which the array
element is yielded (current value). If item
is an expression, it
can contain the current value, the index, and the array
.
item
array
...body
sibilant(each number [ 1 2 3 ] (console.log number))
js[ 1, 2, 3 ].forEach((function(number) {
/* src/macros/lists.sibilant:92:17 */
return console.log(number);
}))
sibilant(each (letter index) `[ a b c d ]
(set letters letter index)
(pipe letter (.to-upper-case) (console.log)))
js[ "a", "b", "c", "d" ].forEach((function(letter, index) {
/* src/macros/lists.sibilant:93:17 */
letters[letter] = index;
return console.log(letter.toUpperCase());
}))
references
returns true if the array arr
has a length of zero
arr
sibilant(empty? [])
js0 === [].length
returns true if haystack
does NOT include needle
.
haystack
can be a string or array/list
haystack
needle
sibilant(excludes? 'hello 10)
js"hello".indexOf(10) === -1
sibilant(excludes? `[ Veni vidi vici] 'attenti)
js[ "Veni", "vidi", "vici" ].indexOf("attenti") === -1
gets the first element of arr
arr
sibilant(first `[ a b c d e ])
js[ "a", "b", "c", "d", "e" ][0]
returns true if haystack
includes needle
. haystack
can be a string or array/list.
haystack
needle
sibilant(includes? 'hello 'h)
js"hello".indexOf("h") !== -1
sibilant(includes? `[ Veni vidi vici] 'vidi)
js[ "Veni", "vidi", "vici" ].indexOf("vidi") !== -1
combines elements of array arr
into a string, inserting
glue
string between each element. if glue
is omitted (only one
argument provided), the elements of arr
are joined with an empty
string
arr
glue
sibilant(join `[ a few words ] ", " )
js[ "a", "few", "words" ].join(", ")
sibilant(join `[ several more words ])
js[ "several", "more", "words" ].join("")
fetches just the last element of arr
by slicing.
arr
sibilant(last [ 1 2 3 ])
js[ 1, 2, 3 ].slice(-1)[0]
fetches length attribute from arr
arr
sibilant(length [ 1 2 3 ])
js[ 1, 2, 3 ].length
fetches all but the first item of arr
arr
sibilant(rest [ 1 2 3 ])
js[ 1, 2, 3 ].slice(1)
gets the second element of arr
arr
sibilant(second `[ a b c d e ])
js[ "a", "b", "c", "d", "e" ][1]
This is the macro that is called when brackets ([]
) are
used. Emits a javascript array literal. Splats (...
) can be used to
in-line other arrays.
args
sibilant(list 1 2 3 4 5)
js[ 1, 2, 3, 4, 5 ]
sibilant[ 'a 'b 'c 'd 'e ]
js[ "a", "b", "c", "d", "e" ]
sibilant[ a b ...c d ...e ]
js[ a, b ].concat(c, [ d ], e)
gets the third element of arr
arr
sibilant(third `[ a b c d e ])
js[ "a", "b", "c", "d", "e" ][2]
returns the last element if all elements of args
are truthy, or the
first non-truthy element if it exists
...args
sibilant(and (string? "string") (number? 10) (= 1 1))
js(typeof "string" === "string" && typeof 10 === "number" && 1 === 1)
boolean negation, as determined by javascript truthiness
argumentsexp
sibilant(not (string? 1))
js!(typeof 1 === "string")
references
retreives object properties, potentially deeply. If more than one keys
are provided,
get fetches deeply into nested objects or arrays.
When javascript dot notation can be used (a.b = 3
), it is.
Otherwise, bracket notation is used.
obj
...keys
sibilant(get an-object 'static-attribute-name)
jsanObject.staticAttributeName
sibilant(get object dynamic-attribute-name)
jsobject[dynamicAttributeName]
sibilant(get object "these attributes" "can't be dotted")
jsobject["these attributes"]["can't be dotted"]
sibilant(get array 0)
jsarray[0]
sibilant(get object 'a 'b c)
jsobject.a.b[c]
sibilant(get array 0 1 2)
jsarray[0][1][2]
this is the macro that is called by braces ({}
). Produces a
javascript object out of alternating key value pairs. To repeat an
entry as both key and value, use the & character, as shown in examples. To use the value of a variable as a key, use the backtick character before the key. These can be combined
...pairs
sibilant(hash k1 v1 k2 v2)
js{
k1: v1,
k2: v2
}
sibilant(hash 'key 'value)
js{ "key": "value" }
sibilant{ 'key { 'nested 'value } }
js{ "key": { "nested": "value" } }
sibilant{ kv1& kv2& }
js{
kv1: kv1,
kv2: kv2
}
sibilant{ `variable 1 }
js(function() {
var hash$1 = { };
hash$1[variable] = 1;
return hash$1;
}).call(this)
sibilant{ `variable & }
js(function() {
var hash$2 = { };
hash$2[variable] = variable;
return hash$2;
}).call(this)
assigns object properties to arr
in pairs, alternating between keys and values.
When javascript dot notation can be used (a.b = 3
), it is. Otherwise, bracket notation is used
arr
...kv-pairs
sibilant(set an-object 'static-attribute-name 'value)
jsanObject.staticAttributeName = "value";
sibilant(set object dynamic-attribute-name "key name determined at runtime")
jsobject[dynamicAttributeName] = "key name determined at runtime";
sibilant(set array 0 "first element of array")
jsarray[0] = "first element of array";
sibilant(set object "can't be dotted" 'value)
jsobject["can't be dotted"] = "value";
sibilant(set object 'first-attribute 'first-value
'second-attribute 'second-value)
jsobject.firstAttribute = "firstValue";
object.secondAttribute = "secondValue";
tests any number of alternating-conditions-and-branches
. If
an odd number of branches are supplied, the final branch is a
default else clause. To evaluate more than one expression as a
branch, use the do
macro, as shown in the examples:
...alternating-conditions-and-branches
sibilant(if true (console.log 'here))
js(function() {
if (true) {
return console.log("here");
}
}).call(this)
sibilant(if (= 1 arguments.length) (console.log "one argument")
(= 'blue favorite-color) (console.log "blue")
(assign examples 'difficult))
js(function() {
if (1 === arguments.length) {
return console.log("one argument");
} else if ("blue" === favoriteColor) {
return console.log("blue");
} else {
return examples = "difficult";
}
}).call(this)
sibilant(if (foo?) (do (a b)
(c))
(bar?) (do (baz)
(wibble))
(do (d e)
(console.log 'default)))
js(function() {
if (foo__QUERY()) {
a(b);
return c();
} else if (bar__QUERY()) {
baz();
return wibble();
} else {
d(e);
return console.log("default");
}
}).call(this)
short circuiting operator returns the first element of args
that evaluates to be truthy
...args
sibilant(or (= 1 2) (string? []) "one is not two and an array is not a string")
js(1 === 2 || typeof [] === "string" || "one is not two and an array is not a string")
the simplest way to conditionally execute code.
argumentscond
if-true
if-false
sibilant(ternary (< 50 100)
"fifty is less than 100"
"fifty is more than 100")
js(50 < 100) ? "fifty is less than 100" : "fifty is more than 100"
evaluates statements in body
if condition
is falsy. body
is scoped in a self-evaluating function to support having a
return value from the if statement.
condition
...body
sibilant(unless (< 3 i) (console.log i) (get arr i))
js(function() {
if (!(3 < i)) {
console.log(i);
return arr[i];
}
}).call(this)
evaluates statements in body
if condition
is true. body
is scoped in a self-evaluating function to support having a
return value from the if statement.
condition
...body
sibilant(when (< 3 i) (console.log i) (get arr i))
js(function() {
if (3 < i) {
console.log(i);
return arr[i];
}
}).call(this)
calls the function fn
with arguments passed as an array in arglist
fn
arglist
sibilant(apply my-function [ first-arg second-arg third-arg ])
jsmyFunction.apply(this, [ firstArg, secondArg, thirdArg ])
transforms function arguments into an array, using the Array prototype's slice
arguments...args
sibilant(arguments)
jsArray.prototype.slice.call(arguments)
This is the macro that is executed when a function is the first
element in an expression. Assuming that there is no macro named
a
, (a b c)
internatlly compiles to (call a b c)
. splats (...
)
can be used in function calls.
fn-name
...args
sibilant(call a b c)
jsa(b, c)
sibilant(call a b ...c)
jsa.apply(this, [ b ].concat(c))
sibilant(call a ...args)
jsa.apply(this, args)
returns true if all of the things
are functions
...things
sibilant(function? fn)
jstypeof fn === "function"
sibilant(function? err cb)
js(typeof err === "function" && typeof cb === "function")
Defines a lambda/function/closure in Sibilant. Equivalent to
the function
keyword in JavaScript. Most of the time args
is a
paren-wrapped list of arguments, which can include one triple-dotted
splat in the terminal position. The last expression of body
will be
returned. Aliased as #
, as shown in examples.
args-or-options
...body
sibilant(lambda (a b c) (|> a (+ b) (/ c)))
js(function(a, b, c) {
/* src/macros/lambda.sibilant:9:17 */
return ((a + b) / c);
})
sibilant(lambda (a b ...numbers)
(console.log ("a: "a", b: "b""))
(numbers.map (#-> (+ 10))))
js(function(a, b, numbers) {
/* src/macros/lambda.sibilant:10:0 */
var numbers = Array.prototype.slice.call(arguments, 2);
console.log(("a: " + a + ", b: " + b + ""));
return numbers.map((function() {
/* src/macros/lambda.sibilant:12:21 */
return (arguments[0] + 10);
}));
})
sibilant(#({ destructured-object }) (destructured-object))
js(function(destructured_ob$1) {
/* src/macros/lambda.sibilant:13:0 */
var destructuredObject = destructured_ob$1.destructuredObject;
return destructuredObject();
})
sibilant(#([ one two three ]) { one& two& three& })
js(function(one_two_three$1) {
/* src/macros/lambda.sibilant:14:0 */
var one = one_two_three$1[0],
two = one_two_three$1[1],
three = one_two_three$1[2];
return {
one: one,
two: two,
three: three
};
})
sibilant(|> document.body
(.add-event-listener
(#(event)
(console.log ("click at point ("event.x","event.y")"))
(event.prevent-default))))
jsdocument.body.addEventListener((function(event) {
/* src/macros/lambda.sibilant:17:5 */
console.log(("click at point (" + event.x + "," + event.y + ")"));
return event.preventDefault();
}))
uses the javascript new keyword to construct an object using
constructor
, with args
passed as arguments to the constructor.
constructor
...args
sibilant(new RegExp "hello" 'g)
js(new RegExp("hello", "g"))
most often called as its alias, #->
, pipe-thunk applies a pipe chain to the argument of a function and returns the result
...calls
sibilant(.map `[ a b c ] (#-> (.to-upper-case) (concat " is a letter")))
js[ "a", "b", "c" ].map((function() {
/* src/macros/pipe.sibilant:54:34 */
return (arguments[0].toUpperCase() + " is a letter");
}))
executes the body
inside of a self-executing function. The
last statement/expression of the body is returned.
...body
sibilant(scoped true)
js(function() {
/* src/macros/lambda.sibilant:212:16 */
return true;
}).call(this)
sibilant(scoped (var a 1) (+ a 2))
js(function() {
/* src/macros/lambda.sibilant:212:30 */
var a = 1;
return (a + 2);
}).call(this)
calls the method
on object
as a function with args
as the arguments
object
method
...args
sibilant(send object method first-argument second-argument third-argument)
jsobject.method(firstArgument, secondArgument, thirdArgument)
most often called as its alias, #>
, thunk creates a function
with no named arguments. To refer to arguments anonymously, use #n,
such as #0 for the first argument.
...body
sibilant(.map [ 1 2 3 ] (#> (+ 1(argument'0'))))
js[ 1, 2, 3 ].map((function() {
/* src/macros/lambda.sibilant:70:34 */
return (1 + arguments[0]);
}))
sibilant(window.set-timeout (#> (console.log 'here)) 10)
jswindow.setTimeout((function() {
/* src/macros/lambda.sibilant:71:38 */
return console.log("here");
}), 10)
assigns alternating keys and values in args
. This works much
like var, but without the var keyword. It is important to
understand variable scope in javascript in order to use this macro safely.
This macro supports destructuring, as shown in examples
...pairs
sibilant(assign a 1)
jsa = 1;
sibilant(assign a: 1, b: 2)
jsa = 1;
b = 2;
sibilant(assign [ right left ] [ left right ])
jsleft_right$1 = [ left, right ];
right = left_right$1[0];
left = left_right$1[1];
left_right$1 = undefined;
sibilant(assign {log} console)
jslog = console.log;
sibilant(assign [ a b ] c)
jsa = c[0];
b = c[1];
sibilant(assign { a b } c
[ x y ] a)
jsa = c.a;
b = c.b;
x = a[0];
y = a[1];
inserts contents
transpiled to javascript as a comment in the
output file, removing it from execution.
...contents
sibilant(comment (scoped 1))
js// (function() {
// /* src/macros/misc.sibilant:25:23 */
//
// return 1;
// }).call(this)
defines a function in the local scope. name
is the
variable name that the function will be stored as. Note that sibilant
does *not* support hoisting. args
is a paren-wrapped list of
arguments, as shown in the examples. body
can be any number of
statements, the last of which will be the return value of the
function.
name
args
...body
sibilant(def square (x) (* x x))
jsvar square = (function square$(x) {
/* square src/macros/lambda.sibilant:157:17 */
return (x * x);
});
loads and transpiles content from another file or files
as if
it were written in-line. This is distinct from node's require
function, as include will drop the output javascript directly in
place of the include statement. Namespaced macros defined in the
included file will not by default be imported into the current macro
namespace. Include will append ".sibilant" to the end of files, and
will also use node's module system to resolve sibilant files from
other packages. As a noncompiling example, it is possible to npm
install sibilant-react
and (include "sibilant-react/macros")
,
which introduces the react
macro namespace.
...files
uses the javascript instanceof
operator to check if item
is of type
.
item
type
sibilant(instance-of? (new Date) Date)
js(transpile(item)" instanceof "transpile(type))
outputs debug information about arg
. If label
is
omitted (only one argument is provided), the name of the variable or
expression of that first expression will be logged. Aliased as pretty-log
label
arg
sibilant(log-pretty 'my-label value)
jsconsole.log(("src/macros/misc.sibilant:40" + " " + "myLabel" + " = " + prettify(value)))
sibilant(log-pretty (+ 1 2))
jsconsole.log(("src/macros/misc.sibilant:41" + " " + "(+ 1 2)" + " = " + prettify((1 + 2))))
Defines a macro. The arguments are the same as for def: the
function defined with args
and body
will be stored in the current
macro namespace as name
. The last statement of body
will be
returned, and should either be an array of strings and/or sibilant ast
nodes, or a sibilant ast node. Most of the time this is accomplished
through use of quote
and unquote
. Note that there are no examples
for this macro, but hopefully there will be a tutorial.
name
args
...body
Equivalent to defining a macro and immediately evaluating it.
Evaluates body
at compile time in the compiler context. Note that
the result is inserted directly into the code, not as a string. Often you will want to use this in conjunction with quote
or comment, as shown in the examples.
...body
sibilant(comment (meta (sibilant.version)))
js// 0.5.5
sibilant(quote (meta (sibilant.version)))
js"0.5.5"
inserts the result of each subsequent call in calls
as the
second argument to the next macro. This is very much akin to clojure's
thread-first arrow or elixir's pipe operator. Advanced: in order to
thread the preceding topic into a position other than the second
position, use the character #
to specify topic position
...calls
sibilant(pipe "a b c d"
.to-upper-case
(.replace "A" "X")
(.split " ")
first
(concat " marks the spot"))
js("a b c d".toUpperCase().replace("A", "X").split(" ")[0] + " marks the spot")
sibilant(pipe "{\"a\": {\"b\": [ 1, 2, 3 ]}}"
JSON.parse
(get 'a)
JSON.stringify)
jsJSON.stringify(JSON.parse("{\"a\": {\"b\": [ 1, 2, 3 ]}}").a)
sibilant(pipe 3 (+ 1) (var a #))
jsvar a = (3 + 1);
references
generates a function intended to be used in conjunction with pipe or pipe-thunk that does not interrupt the main flow of the pipe
argumentsthing
...body
sibilant(|> 2 (tap (+ 5) console.log) (* 10))
js((function() {
/* src/macros/pipe.sibilant:66:9 */
console.log((arguments[0] + 5));
return arguments[0];
})(2) * 10)
sibilant(#-> .to-upper-case (tap console.log) (.split " "))
js(function() {
/* src/macros/pipe.sibilant:64:17 */
return (function() {
/* src/macros/pipe.sibilant:66:9 */
console.log(arguments[0]);
return arguments[0];
})(arguments[0].toUpperCase()).split(" ");
})
throws a new javascript error with arguments as the string
argumentserror
sibilant(throw (new Error "could not find matching socks"))
jsthrow (new Error("could not find matching socks"))
evaluates the body
as long as condition
is falsy,
returning the value of the last expression in block
when condition
ceases to be falsy. See also while
condition
...body
sibilant(until (< 5 i) (console.log i) (incr i))
js(function() {
var while$2 = undefined;
while (!(5 < i)) {
while$2 = (function() {
console.log(i);
return ((i)++);
}).call(this);
};
return while$2;
}).call(this)
evaluates the body
as long as condition
is truthy,
returning the value of the last expression in block
when condition
ceases to be truthy. See also until
condition
...body
sibilant(while (> 5 i) (console.log i) (decr i))
js(function() {
var while$1 = undefined;
while (5 > i) {
while$1 = (function() {
console.log(i);
return ((i)--);
}).call(this);
};
return while$1;
}).call(this)
stores a duplicate copy of current-macro-name
as
new-macro-name
in current namespace. No output.
current-macro-name
new-macro-name
deletes each macro name in macro-names
from the current namespace. Use carefully
...macro-names
moves macro from current-macro-name
to new-macro-name
. Use carefully
current-macro-name
new-macro-name
subtracts each subsequent element of args
...args
sibilant(- 2 1)
js(2 - 1)
sibilant(- 10 5 1)
js(10 - 5 - 1)
divides each subsequent element of args
...args
sibilant(/ 1 2)
js(1 / 2)
sibilant(/ 1 2 3)
js(1 / 2 / 3)
returns true if number
is divisible by 2 with no remainder
number
sibilant(even? 10)
js0 === (10 % 2)
increments item
by increment
item
increment
sibilant(incr-by n 5)
jsn += 5
returns true if all of the things
are numbers, as tested
with typeof
...things
sibilant(number? 1)
jstypeof 1 === "number"
sibilant(number? 1 2 3)
js(typeof 1 === "number" && typeof 2 === "number" && typeof 3 === "number")
returns true if number
is not divisible by 2
number
sibilant(odd? 5)
js1 === (5 % 2)
predicate to test for equality with zero
argumentsitem
sibilant(zero? n)
jsn === 0
uses the javascript delete keyword on any number of objects
.
Use in conjunction with get or dotted literal notation (a.b).
...objects
sibilant(delete object.a object.b)
jsdelete object.a;
delete object.b;
sibilant(delete (get object attribute) (get object "other attribute"))
jsdelete object[attribute];
delete object["other attribute"];
iterates over each attribute in obj
as
obj
...body
sibilant(each-key key { a 1 b 2 } (console.log key))
jsObject.keys({
a: 1,
b: 2
}).forEach((function(key) {
/* src/macros/hash.sibilant:121:14 */
return console.log(key);
}))
checks if object
has property key
. returns true or false.
object
key
sibilant(has-key? object 'a)
jsobject.hasOwnProperty("a")
returns the property names of obj
.
obj
sibilant(keys { a 1 b 2 })
jsObject.keys({
a: 1,
b: 2
})
references
similar to match? but builds a regex out of the pattern
and flags
.
string
pattern
flags
sibilant(match-regex? 'word "^[a-z]+$" 'i)
js"word".match((new RegExp("^[a-z]+$", "i")))
returns true if the string
matches regexp
. Deprecated in
preference to .match
(send dot-invocation).
regexp
string
sibilant(match? (regex "^[a-z]+$" 'i) 'word)
js"word".match((new RegExp("^[a-z]+$", "i")))
builds a regex using pattern
and flags
as arguments to the RegExp constructor
pattern
flags
sibilant(regex "[0-9]+")
js(new RegExp("[0-9]+", undefined))
sibilant(regex "0x[0-9a-f]+" 'i)
js(new RegExp("0x[0-9a-f]+", "i"))
replaces the first occurance of pattern
(as a regex) with replacement
string
pattern
replacement
sibilant(replace "hello world" "l+o" "y there,")
js"hello world".replace((new RegExp("l+o", undefined)), "y there,")
replaces all occurrances of pattern
(as a regex) with replacement
string
pattern
replacement
sibilant(replace-all "503-555-1212" "[0-9]" "#")
js"503-555-1212".replace((new RegExp("[0-9]", "g")), "#")
adds args
using the javascript + operator. Since javascript
overloads this for string concatenation, this macro can be used for
this as well.
...args
sibilant(+ 1 2 3)
js(1 + 2 + 3)
sibilant(+ 'hello 'world)
js("hello" + "world")
checks if a string is identical to the lower-cased version of itself
argumentsstr
sibilant(lower-case? "abc")
js("abc".toUpperCase() !== "abc" && "abc".toLowerCase() === "abc")
returns true if all of the things
are javascript strings
...things
sibilant(string? test-object)
jstypeof testObject === "string"
sibilant(string? 'yes 'yes 'yes)
js(typeof "yes" === "string" && typeof "yes" === "string" && typeof "yes" === "string")
checks if a string is identical to the upper-cased version of itself
argumentsstr
sibilant(lower-case? "abc")
js("abc".toUpperCase() !== "abc" && "abc".toLowerCase() === "abc")
returns true if thing
is an array in javascript. aliased as
list?
.
thing
sibilant(array? arr)
js(arr && "object" === typeof arr && "Array" === arr.constructor.name)
double-negates expr
, converting it to a boolean
expr
sibilant(as-boolean 0)
js(!!(0))
sibilant(as-boolean true)
js(!!(true))
coerces expr
to a number. Currently implemented through the use of Number()
expr
sibilant(as-number "0.1")
jsNumber("0.1")
sibilant(as-number 0.1)
jsNumber(0.1)
references
returns true if none of the things
are undefined, as tested
with typeof. This is the inverse of defined?
...things
sibilant(defined? variable)
jstypeof variable !== "undefined"
sibilant(defined? var1 var2 var3)
js(typeof var1 !== "undefined" && typeof var2 !== "undefined" && typeof var3 !== "undefined")
similar to the javascript truthiness predicate as-boolean, returns true unless the thing
is undefined or null
thing
sibilant(exists? window)
js(typeof window !== "undefined" && window !== null)
returns true if thing
is an object that is not an array in javascript. aliased as
object?
.
thing
sibilant(object? arr)
js("object" === typeof arr && arr !== null && arr.constructor.name !== "Array")
returns true if all of the things
are undefined, as tested
with typeof, not equality with literal undefined. This is the
inverse of defined?
...things
sibilant(undefined? argument)
jstypeof argument === "undefined"
sibilant(undefined? 1 2 undefined)
js(typeof 1 === "undefined" && typeof 2 === "undefined" && typeof undefined === "undefined")
sets default values for variables in current scope. pairs
are
alternating variable names and default values
...pairs
sibilant(default a 10 b 20)
jsa = (typeof a !== "undefined") ? a : 10;
b = (typeof b !== "undefined") ? b : 20;
registers variables in pairs
inside of the current scope using the javascript var keyword.
destructuring from arrays and objects is also supported, as shown in the examples. Note: :
and ,
are always ignored.
...pairs
sibilant(var a)
jsvar a = undefined;
sibilant(var a: 1, b: 2)
jsvar a = 1,
b = 2;
sibilant(var a [ 1 2 3 ]
[ b c d ] a)
jsvar a = [ 1, 2, 3 ],
b = a[0],
c = a[1],
d = a[2];
sibilant(var {attribute} { attribute: 'hi })
jsvar attribute = ({ attribute: "hi" }).attribute;
sibilant(var {log dir} console)
jsvar log = console.log,
dir = console.dir;
sibilant(var {a}: {a 1 b 2},
{c d}: {c 3 d 4})
jsvar a = ({
a: 1,
b: 2
}).a,
c_d$1 = {
c: 3,
d: 4
},
c = c_d$1.c,
d = c_d$1.d,
c_d$1 = undefined;
inserts a pragma for source-mapping-url
argumentsurl
sibilant(source-mapping-url "/example.map")
js//# sourceMappingURL=/example.map
adds additional
elements onto the right-side (tail) of list
. deprecated
list
...additional
sibilant(append [ 1 2 3 ] 4 5 6)
js[ 1, 2, 3 ].concat([ 4, 5, 6 ])
builds an array with first
as the zeroth index and the
elements provided by array rest
as the subsequent elements, as
siblings with first
.
first
rest
sibilant(cons 1 [ 2 3 4 ])
js[ 1 ].concat([ 2, 3, 4 ])
uses the javascript switch construction to test equality. documentation todo: needs better description
argumentsobj
...cases
sibilant(switch char
('a "it was an a")
('b (console.log "found a b!")
"it was a b")
([1 2 3 4 5] "it was an integer from one to five")
(default "not sure"))
js(function() {
switch(char) {
case "a":
return "it was an a";
case "b":
console.log("found a b!");
return "it was a b";
case 1:
case 2:
case 3:
case 4:
case 5:
return "it was an integer from one to five";
default:
return "not sure";
}
}).call(this)
Made with love in 2016 by Jacob Rothstein
Colophon: sibilant, react, react-bootstrap, redux, highlightjs