This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Some experiments for memoization functions on Fibonacci sequence. */ | |
/* This uses the SpiderMonkey JS Shell functions print and dateNow for its output. */ | |
let | |
fix= | |
f=>( | |
(f=>f(f)) | |
(g=>f((...a)=>g(g)(...a)))), | |
memo= | |
f=>( | |
(map=>a=>( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((fix=>(fix(z=>(f,a)=>(b,...c)=>(b===void 0?a:z(f,f(a,b))(...c))) | |
((a,b)=>(a+'\n\t'+((b%3===0?'Fizz':'')+(b%5===0?'Buzz':'')||b)), | |
'FizzBuzz 1-100:')) | |
(...fix(z=>(m,n,...y)=>(n<m?y:z(m+1,n,...y,m)))(1,100))) | |
(f=>((f=>f(f))(g=>f((...a)=>g(g)(...a)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- HUMAN RESOURCE MACHINE PROGRAM -- | |
a: | |
COMMENT 0 | |
COPYFROM 24 | |
COPYTO 23 | |
COPYTO 22 | |
COPYTO 0 | |
BUMPDN 0 | |
BUMPUP 23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* everysooften(num,val){ | |
let x=num; | |
while(0<--x) | |
yield; | |
yield val; | |
yield* everysooften(num,val)} | |
function* combine(...its){ | |
while(true) | |
yield its | |
.map(it=>it.next().value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Original: | |
// | |
//const map = (f, [x, …xs]) => ( | |
// (x === undefined && xs.length === 0) ? [] | |
// : [f(x), …map(f, xs)] | |
//); | |
const map=(f,array)=>{ | |
const iterator=array[Symbol.iterator]() | |
let {done,value}=iterator.next() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://gist.github.com/liorean/58667acd9b8b4554a9c7b4740065e93c | |
const map=(f,array)=>{ | |
const iterator=array[Symbol.iterator]() | |
let {done,value}=iterator.next() | |
if(done){ | |
if('return' in iterator) | |
iterator.return() | |
return []} | |
return [f(value),...map(f,iterator)]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Continuing from https://gist.github.com/liorean/58667acd9b8b4554a9c7b4740065e93c | |
// and https://gist.github.com/liorean/fa6b1f147df2dd3bd0c99e3254dd21f0 | |
const map=(f,array)=>{ | |
const iterator=array[Symbol.iterator]() | |
return{ | |
[Symbol.iterator](){return this} | |
,next(){ | |
let {done,value}=iterator.next() | |
if(done){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- HUMAN RESOURCE MACHINE PROGRAM -- | |
INBOX | |
OUTBOX | |
INBOX | |
OUTBOX | |
INBOX | |
OUTBOX | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- HUMAN RESOURCE MACHINE PROGRAM -- | |
INBOX | |
OUTBOX | |
INBOX | |
OUTBOX | |
INBOX | |
OUTBOX | |
INBOX | |
OUTBOX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- HUMAN RESOURCE MACHINE PROGRAM -- | |
a: | |
INBOX | |
OUTBOX | |
JUMP a | |
OlderNewer