λ-wiki
::
iterations
+
| 1 |
help
|
pages
|
skin
|
login
|
code
www!k! v.20120610
! CE SITE NECESSITE JAVASCRIPT !
λ-wiki :: éditeur
{center {a functions} [[booleans]] [[iterations]] [[recursion]] [[tail_recursion]] [[factorial]]} _h1 iterations _p A subset of iteratives processes can be used with the form : {div {@ class:terminal;}°°{for :i in [a,b] do body}°°} _ul the name of the unique variable must be prefixed by a colon {y :}, _ul incremented in the interval [a,b], so (b-a+1) times, _ul the body can contain one or more references of the variable, _ul the curly braces of the math functions in the body {y must be} replaced by simple parenthesis. _p {b Note :} the "map" spécial function seems to be a better way, see page [[tutorial]]. _h6 1) examples {div {@ class:terminal;} _h6 1) computing power() : n{sup 2} °°{for :i in [1,10] do (br):i(sup 2) = (mult :i :i) }°° _h6 2) computing sqrt() : √n °°{for :j in [1,10] do (br)√:j = (sqrt :j) }°° _h6 3) computing factorial() : n! °°{for :xx in [1,10] do (br):xx! = (fact :xx) }°° _h6 4) computing the sum of integers : Σ{sub 0}{sup n} The dynamic function mysum is defined by : {y n*(n+1)/2} : {define mysum :n = (quot (mult :n (add :n 1)) 2)} °°{for :foo in [1,10] do {br}Σ{sub 0}{sup :foo} = (mysum :foo) }°° } _h6 2) results {div {@ border:1px solid; padding:5px; margin-top:5px;} {div {@ float:left; width:15%;} _h6 n{sup 2} {for :i in [1,10] do {br}:i(sup 2) = (mult :i :i) } } {div {@ float:left; width:30%;} _h6 √n {for :j in [1,10] do {br}√:j = (sqrt :j) } } {div {@ float:left; width:30%;} _h6 n! {for :xx in [1,10] do {br}:xx! = (fact :xx) } } {div {@ float:left; width:15%;} _h6 Σ{sub 0}{sup n} {for :foo in [1,10] do {br}Σ{sub 0}{sup :foo} = (mysum :foo) } } {div {@ clear:both;}} }