Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,39 @@
link printf
procedure main()
fsf1 := partial(fs,f1)
fsf2 := partial(fs,f2)
every s := [ 0, 1, 2, 3 ] |
[ 2, 4, 6, 8 ] do {
printf("\ns := %s\n",list2string(s))
printf("fsf1(s) := %s\n",list2string(fsf1(s)))
printf("fsf2(s) := %s\n",list2string(fsf2(s)))
}
end
procedure partial(f,g) #: partial application of f & g
@( p := create repeat {
s := (r@&source)[1] # return r / get argument s
r := f(g,s) # apply f(g,...)
}
) # create and activate procedure p
return p
end
procedure fs(f,s) #: return list where f is applied to each element of s
every put(r := [], f(!s))
return r
end
procedure f1(n) # double
return n * 2
end
procedure f2(n) #: square
return n ^ 2
end
procedure list2string(L) #: format list as a string
every (s := "[ ") ||:= !L || " "
return s || "]"
end