RosettaCodeData/Task/Loop-over-multiple-arrays-simultaneously/Lambdatalk/loop-over-multiple-arrays-simultaneously.lambdatalk
2023-07-01 13:44:08 -04:00

52 lines
1 KiB
Text

1) loop over 3 sentences of equal length and returning 3 sentences
{def A a b c} -> A
{def B A B C} -> B
{def C 1 2 3} -> C
{S.map {lambda {:i} {br}{S.get :i {A}}
{S.get :i {B}}
{S.get :i {C}} }
{S.serie 0 {- {S.length {A}} 1}}}
->
a A 1
b B 2
c C 3
2) loop over 3 arrays of equal length and returning 3 arrays
{def maps
{lambda {:a :b :c}
{S.map {{lambda {:a :b :c :i}
{br}{A.new {A.get :i :a}
{A.get :i :b}
{A.get :i :c}} } :a :b :c}
{S.serie 0 {- {A.length :a} 1}}}}}
-> maps
{def P {A.new a b c}} -> P
{def Q {A.new A B C}} -> Q
{def R {A.new 1 2 3}} -> R
{maps {P} {Q} {R}}
->
[a,A,1]
[b,B,2]
[c,C,3]
3) loop over 3 words of inegal length and returning words
{def X James} -> X
{def Y Bond} -> Y
{def Z 007} -> Z
{S.map {lambda {:i} {br}{W.get :i {X}}
{W.get :i {Y}}
{W.get :i {Z}} }
{S.serie 0 {- {W.length {X}} 1}}}
->
J B 0
a o 0
m n 7
e d
s