λ-wiki
::
tutorial
+
| 1 |
help
|
pages
|
skin
|
login
|
code
www!k! v.20120610
! CE SITE NECESSITE JAVASCRIPT !
λ-wiki :: éditeur
_h1 tutorial _p {u In case of a bad display, please reload the page to actualise the parser.} _h6 1) primitives {pre {@ class:terminal;} ? '{+ 1 2 3 4}' > {+ 1 2 3 4} ? '{+ 1 2 3 -6}' > {+ 1 2 3 -6} ? '{- 1 2 3}' > {- 1 2 3} ? '{sqrt {+ {* 3 3} {* 4 4}}}' > {sqrt {+ {* 3 3} {* 4 4}}} ? '{fact 10}' > {fact 10} } _h6 2) constants {pre {@ class:terminal;} ? '{PI}' > {PI} ? '{E}' > {E} } _h6 3) booleans {pre {@ class:terminal;} ? '{if true then YES else NO}' > {if true then YES else NO} ? '{if {lessthen 1 2} then YES else NO}' > {if {lessthen 1 2} then YES else NO} ? '{if {equal 1 2} then YES else NO}' > {if {equal 1 2} then YES else NO} ? '{if {greaterthen 2 1} then YES else NO}' > {if {greaterthen 2 1} then YES else NO} ? '{if {equal {sqrt 4} 2} then YES, {sqrt 4} = 2 else NO}' > {if {equal {sqrt 4} 2} then YES, '{sqrt 4}' = 2 else NO} } _h6 4) user's functions and vars {pre {@ class:terminal;} ? '{define square :x = (* :x :x)}' > {define square :x = (* :x :x)} ? '{inspect_function square}' > {inspect_function square} ? '{square 3}' > {square 3} ? '{square 12}' > {square 12} ? '{define circonference :r = (* 2 (PI) :r)}' > {define circonference :r = (* 2 (PI) :r)} ? '{circonference 1}' > {circonference 1} ? '{define hypothenuse :a :b = (sqrt (+ (* :a :a) (* :b :b)))}' > {define hypothenuse :a :b = (sqrt (+ (* :a :a) (* :b :b)))} ? '{hypothenuse 3 4}' > {hypothenuse 3 4} } _h6 5) serie, map {pre {@ class:terminal;} ? '{serie 1 34}' > {serie 1 34} ? '{map square {serie 1 27}}' > {map square {serie 1 27}} ? '{map sqrt {serie 1 7}}' > {map sqrt {serie 1 7}} ? '{+ {serie 1 1000}}' > {+ {serie 1 1000}} ? '{+ {map square {serie 1 1000}}}' > {+ {map square {serie 1 1000}}} ? '{map fact {serie 1 10}}' > {map fact {serie 1 10}} ? '{map inv {serie 1 10}}' > {map inv {serie 1 9}} ? '{define foo = (map fact (serie 0 10))}' > {define foo = (map fact (serie 0 10))} ? '{foo}' > {foo} ? '{+ 2 {map inv {foo}}}' (why +2 ? some work to do !) > {+ 2 {map inv {foo}}} which is not far from euler's number = {E} } _h6 6) recursion {pre {@ class:terminal;} ? '{define myfact :r :i :n = (if (greaterthen :i :n) then :r else (myfact (* :r :i) (+ 1 :i) :n) ) }' > {define myfact :r :i :n = (if (greaterthen :i :n) then :r else (myfact (* :r :i) (+ :i 1) :n) ) } ? '{define factorial :n = (1 1 :n)}' > {define factorial :n = (myfact 1 1 :n)} ? '{factorial 10}' > {factorial 10} } _h6 7) inspect functions : html tags, static, dynamic {pre {@ class:terminal;} 1) {lib html} 2) {lib core} 3) {lib dyn} }