Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Y-combinator/Vim-Script/y-combinator-1.vim
Normal file
22
Task/Y-combinator/Vim-Script/y-combinator-1.vim
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
" Translated from Python. Works with: Vim 7.0
|
||||
|
||||
func! Lambx(sig, expr, dict)
|
||||
let fanon = {'d': a:dict}
|
||||
exec printf("
|
||||
\func fanon.f(%s) dict\n
|
||||
\ return %s\n
|
||||
\endfunc",
|
||||
\ a:sig, a:expr)
|
||||
return fanon
|
||||
endfunc
|
||||
|
||||
func! Callx(fanon, arglist)
|
||||
return call(a:fanon.f, a:arglist, a:fanon.d)
|
||||
endfunc
|
||||
|
||||
let g:Y = Lambx('f', 'Callx(Lambx("x", "Callx(a:x, [a:x])", {}), [Lambx("y", ''Callx(self.f, [Lambx("...", "Callx(Callx(self.y, [self.y]), a:000)", {"y": a:y})])'', {"f": a:f})])', {})
|
||||
|
||||
let g:fac = Lambx('f', 'Lambx("n", "a:n<2 ? 1 : a:n * Callx(self.f, [a:n-1])", {"f": a:f})', {})
|
||||
|
||||
echo Callx(Callx(g:Y, [g:fac]), [5])
|
||||
echo map(range(10), 'Callx(Callx(Y, [fac]), [v:val])')
|
||||
9
Task/Y-combinator/Vim-Script/y-combinator-2.vim
Normal file
9
Task/Y-combinator/Vim-Script/y-combinator-2.vim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
if !has("lambda")
|
||||
echoerr 'Lambda feature required'
|
||||
finish
|
||||
endif
|
||||
let Y = {f -> {x -> x(x)}({y -> f({... -> call(y(y), a:000)})})}
|
||||
let Fac = {f -> {n -> n<2 ? 1 : n * f(n-1)}}
|
||||
|
||||
echo Y(Fac)(5)
|
||||
echo map(range(10), 'Y(Fac)(v:val)')
|
||||
Loading…
Add table
Add a link
Reference in a new issue