You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to hold some state between createFn calls. For instance, to be able to generate fibonacci sequence:
constnext=last=>{if(last.length<2){last.push(1);return1;}constitem=last.shift()+last[0];last.push(item);returnitem;};// beforeconstf=()=>{constlast=[];return()=>next(last);}constfibonacciSequence=create(f(),10);// okconstfibonacciGenerator=create(f());// not ok, will work only once// afterconstfibonacciGenerator=create((index,state)=>{if(!state.last)state.last=[];returnnext(state.last);})
The text was updated successfully, but these errors were encountered:
It would be nice to hold some state between
createFn
calls. For instance, to be able to generate fibonacci sequence:The text was updated successfully, but these errors were encountered: