Defines an alias which when used will call the aliased function.
'add' '+' alias
Checks whether the top element is a block.
type 'block' =
Checks whether the top element is boolean.
type 'boolean' =
Defines a new function with the name given, when called the block passed will be called.
'sq' [ dup * ] define
Pushes a string containing all defined functions on to the stack.
Checks whether there are no elements on the stack.
size 0 eq?
Evaluates the string at the top of the stack as vodka source code.
'1 2 +' eval ;=> [3]
Includes the vodka file at the top of the stack.
'test' include ; Will load the file 'test.vk'
'.vk' concat read eval
Checks whether the top element is an integer.
type 'integer' =
Checks whether the top element is nil.
type 'nil' =
Checks whether the stack contains one or less elements.
size 1 lte?
Checks whether the top element is a string.
type 'string' =
Replaces the element at the top of the stack with a string describing it's type.
123 type ;=> ['integer']
Replaces the number at the top of the stack with it's absolute value.
dup 0 lt?
:neg unless
Adds the top two elements of the stack together.
5 2 add ;=> [7]
Decrements the number at the top of the stack.
1 sub
Divides the second element of the stack by the second. Does integer division only at the moment, this does not round to the nearest integer.
5 2 div ;=> [2]
Calculates the factorial of the number at the top of the stack.
5 fact ;=> [120]
1 swap range :* reduce
Increments the number at the top of the stack.
1 add
Multiples the top two elements of the stack together.
5 2 mult ;=> [10]
Negates the number at the top of the stack.
5 neg ;=> [-5]
Multiplies all values on the stack.
:* stack
Subtracts the top element of the stack from the second.
5 2 sub ;=> [3]
Sums all values on the stack.
:+ stack
Checks whether the top element is 0.
0 eq?
Prints the string representation of the element at the top of the stack.
500 p ;=> 500
Prints the string at the top of the stack to stdout.
'Hello world' print ;=> Hello World
Reads the file at the top of the stack.
'lorem.txt' read ;=> ["Lorem ..."]
Calls the block at the top of the stack.
300 :inc call ;=> [301]
Evaluates the block at the top of the stack if the value below it is true.
300 300 eq? [ "300 equals 300, crazy!" print ] if
. swap if-else
Calls the block at the top of the stack if the condition is true, or the second if the condition is false.
300 300 eq? [ "yes" ] [ "no" ] if-else ;=> ["yes"]
Calls the second element of the stack n times, where n is the top element.
300 :inc 5 times ;=> [305]
swap
wrap :dec swap compose :under compose
:zero?
; 300 5 [dec :inc under] :zero? until
until
; Cleanup counter
pop nil pop
Calls the top element while temporarily removing the second element.
5 'In the way' :dec under ;=> [4 'In the way']
swap without
Calls the top element while temporarily removing the second and third elements.
swap swapp without2
Evaluates the block at the top of the stack if the value below it is false.
swap not swap if
Evaluates the second block while the condition at the top of the stack is false.
5 :dec :zero? until ;=> 0
:not compose while
Evalutes the second block on the third element of the stack while the condition at the top of the stack is true.
5 :dec [ zero? ! ] while ;=> [0]
; Evaluate the condition, while leaving copies of everything
swapp swap dup
swapp swap dup
swapp call
; If condition is false, cleanup
[pop swap pop]
; If condition is still true, ...
[swapp swap dup
swapp swap without2
while]
if-else
Calls the second element while temporarily removing the top element from the stack.
5 :dec 'In the way' without ;=> [4 'In the way']
Calls the third element while temporarily removing the top two elements from the stack.
Adds the second list on the stack to the back of the first.
(1 2 3) (4 5 6) append ;=> [(4 5 6 1 2 3)]
Applies the block at the top of the stack to the elements in the list below.
(1 2 3) :swap apply ;=> [(1 3 2)]
Adds the element at the top of the stack to the end of the list below.
(1 2 3) 4 cons ;=> [(1 2 3 4)]
Replaces the list with it's first element.
(1 2 3 4) head ;=> [1]
Adds the second list on the stack to the front of the first.
(1 2 3) (4 5 6) prepend ;=> [(1 2 3 4 5 6)]
swap append
Applies the function to each pair of elements in the list.
(1 2 3 4) :+ reduce ;=> [10]
wrap :stack compose apply head
Reverses the elements in the list.
(1 2 3) reverse ;=> [(3 2 1)]
Replaces the list with a list containing all but the first of it's elements.
(1 2 3 4) tail ;=> [(2 3 4)]
Calculates the value of a boolean and operation applied to the top two elements of the stack.
true false and ;=> [false]
Compares the top two elements of the stack, pushes -1 if the top element is less than the second, 0 if the elements are equal or 1 if the top element is greater.
1 2 compare ;=> [1]
Checks if the top two elements are equal.
1 1 eq? ;=> [true]
Checks whether the top element is greater than the second.
1 2 gt? ;=> [true]
compare 1 eq?
Checks whether the top element is greater than or equal to the second.
lt? !
Checks whether the top element is less than the second.
1 2 lt? ;=> [false]
compare -1 eq?
Checks whether the top element is less than or equal to the second.
gt? !
Checks whether the top element is not equal to the second. Note: this has a different meaning to `eq? not`. This will return false if the elements are lt? or gt? or eq?. Make sure you understand this properly before using, in most cases you will want to use `eq? not` instead.
'a' 4 neq? ;=> [true]
compare -2 eq?
Returns the opposite of the boolean value at the top of the stack.
:true :false if-else
Calculates the value of a boolean or operation applied to the top two elements of the stack.
true false or ;=> [true]
Composes the two blocks at the top of the stack, forming one single block.
[ dup dec ] :mult compose ;=> [[ dup dec mult ]]
Removes all elements from the stack.
Pushes a copy of the top element to the stack.
Duplicates the top two elements of the stack.
swap dup swapp swap dup swapp
Removes the element from the top of the stack.
Pushes the size of the stack on to the top of the stack.
Calls the block on the top of the stack for each element on the stack, should be used with a reductive function.
size 2 - times
Swaps the top two elements on the stack.
Swaps the second and third elements on the stack.
:swap under
Wraps the block in another block.
:inc wrap [[inc]] eq? ;=> [true]
Joins the top two strings on the stack forming one string.
'Hello' ' World' concat ;=> ['Hello World']
Joins all strings in a list together using the string at the top.
('John' 'Dave' 'Luke') ', ' join ;=> ['John, Dave, Luke']
wrap [swap concat concat] compose reduce
Replaces the string at the top of the stack with an integer of the value represented by the string.
'5' integer ;=> [5]
Replaces the element at the top of the stack with a list containing the element.
5 list ;=> [(5)]
Creates a list with all the numbers from the second element to the top element.
1 5 range ;=> [(1 2 3 4 5)]
Converts the element at the top of the stack into a string.
5 string ;=> ['5']