- or download this
P:\test>p1
perl> sub prompt { printf "What's your name?: "; }
...
perl> main;;
What's your name?: BrowserUk
Hello BrowserUk. Welcome to functional programming!
- or download this
4.4.3.1 Function bindings
A function binding binds a variable to a function value. The general f
+orm of a function binding for variable x is:
...
...
(pn1, ..., pnk) matchn
where the xi are new identifiers.
- or download this
defun generate-tree (phrase)
"Generate a random sentence or phrase,
...
(cons phrase
(generate-tree (random-elt (rewrites phrase)))))
(t (list phrase))))
- or download this
take m ys = case (m,ys) of
(0,_) -> []
(_,[]) -> []
(n,x:xs) -> x : take (n-1) xs
- or download this
#let rec member x btree =
match btree with
...
if x <= y then Node(y, insert x left, right)
else Node(y, left, insert x right);;
val insert : 'a -> 'a btree -> 'a btree = <fun>