Types in Hoon
Types are called Molds.
%d | date
%p | Ship Name
%r | Floating Point
%s | Integer
%t | Text
%ux | Hex
4. Molds (Types) • Guides • developers.urbit.org
Store A Variable and Recast It, Print a Variable
You can not recast variables using themselves, must use another variable name. Aka Things are Typed.
=varname 10
? varname
(%s varname)
(%ux varname)
=varname2 (%ux varname)
? varname2
Store and Print a List
=testlist [1 2 3 4 5]
? testlist
Write and Run a Function
Run each section at a time.
TODO Check types going into function
%- add [1 2]
%- max [100 200]
(gth 12 1)
(mul 2 2)
:: Example Function, input a number and increase it by one
=inc |= [a=@]
(add 1 a)
:: Can also be written as
=inc |=(a=@ (add 1 a))
(inc 12)
=double |=(a=@ (mul a 2))
(double 12)