Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Binary-digits/Lambdatalk/binary-digits-1.lambdatalk
Normal file
21
Task/Binary-digits/Lambdatalk/binary-digits-1.lambdatalk
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{def dec2bin
|
||||
{lambda {:dec}
|
||||
{if {= :dec 0}
|
||||
then 0
|
||||
else {if {< :dec 2}
|
||||
then 1
|
||||
else {dec2bin {floor {/ :dec 2}}}{% :dec 2} }}}}
|
||||
-> dec2bin
|
||||
|
||||
{dec2bin 5} -> 101
|
||||
{dec2bin 5} -> 110010
|
||||
{dec2bin 9000} -> 10001100101000
|
||||
|
||||
{S.map dec2bin 5 50 9000}
|
||||
-> 101 110010 10001100101000
|
||||
|
||||
{S.map {lambda {:i} {br}:i -> {dec2bin :i}} 5 50 9000}
|
||||
->
|
||||
5 -> 101
|
||||
50 -> 110010
|
||||
9000 -> 10001100101000
|
||||
11
Task/Binary-digits/Lambdatalk/binary-digits-2.lambdatalk
Normal file
11
Task/Binary-digits/Lambdatalk/binary-digits-2.lambdatalk
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
1) we add to the lambdatalk's dictionary the Javascript primitive "dec2bin"
|
||||
{script
|
||||
LAMBDATALK.DICT["dec2bin"] = function() {
|
||||
return Number( arguments[0].trim() ).toString(2)
|
||||
};
|
||||
}
|
||||
|
||||
2) we use it in the wiki page:
|
||||
'{S.map dec2bin 5 50 9000}
|
||||
-> 101 110010 10001100101000
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue