λ-wiki
::
math2
+
| 2 |
help
|
pages
|
skin
|
login
|
code
www!k! v.20120610
! CE SITE NECESSITE JAVASCRIPT !
λ-wiki :: éditeur
{center {a {@ alias:math;}maths} {a {@ alias:math2;}functions} [[booleans]] [[iterations]] [[recursion]] } _h1 functions _p Defining functions and variables and using them (@ 12/06/2012). _ul The parser's code can be analyzed here : [[parser|meca/parser.js]], _ul functions hard-coded in the parser's code and dynamically defined in the wiki page can be called like HTML tags (see the list at the end of this page), _ul in the future, it will be possible to define dynamic functions in a different wiki page, as a "global library" to be included by an "include" call, _ul todo : recursion, macros vs functions, namespace, ... _ul ... {div {@ white-space:pre-wrap; border:1px solid grey; padding:5px; background:#fed; color:012;} _h6 defining and using variables in the wiki page ? °°{if true then {b boolean is true} else {i boolean is false} }°° > {if true then {b boolean is true} else {i boolean is false} } ? {set x 3} ? °°{cond {{equal {get x} 2 } q{sqrt 2}q} {{equal {get x} 3 } q{sqrt 3}q} {{equal {get x} 4 } q{sqrt 4}q} {{equal {get x} 5 } q{sqrt 5}q} }°° > {cond {{equal {get x} 2 } x=2 - > q{sqrt 2}q} {{equal {get x} 3 } x=3 - > q{sqrt 3}q} {{equal {get x} 4 } x=4 - > q{sqrt 4}q} {{equal {get x} 5 } x=5 - > q{sqrt 5}q} } _h6 getting a value : ? {span {set A 3} et {set B 4}} > A+B = {add {get A} {get B}} _h6 defining functions in the wiki page ? °°{define diag3 (x y z) {sqrt {add {mult x x} {mult y y} {mult z z}}}}°° > {define diag3 (x y z) °°{sqrt {add {mult x x} {mult y y} {mult z z}}}°° } ? °°{define diag2 (x y) {sqrt {add {mult x x} {mult y y}}}}°° > {define diag2 (x y) °°{sqrt {add {mult x x} {mult y y}}}°° } _h6 using functions defined in the page ? °°{diag3 1 1 1}°° > {diag3 1 1 1} ? °°{diag2 1 1}°° > {diag2 1 1} _h6 using variables and functions ? °°{set N 3}°° > {set N 3} ? °°{set M 4}°° > {set M 4} ? °°{diag2 {get N} {get M}}°° > {diag2 {get N} {get M}} ? °°{equal 2 3}°° > {equal 2 3} ? _h6 listing functions and vars ? °°{lib core}°° > {lib core} ? °°{lib dyn}°° > {lib dyn} ? °°{lib var}°° > {lib var} ? °°{lib foo}°° > {lib foo} }