Changes

Jump to navigation Jump to search
2,622 bytes added ,  22:28, 6 March 2024
Line 22: Line 22:     
[[Image:Combinators.png|center|600px|ZCubes Code Mode Combinator Quick Panel]]
 
[[Image:Combinators.png|center|600px|ZCubes Code Mode Combinator Quick Panel]]
 +
 +
This is WIP. Below are some of the code to try. The Quick Panel shows all the combinators that can be tried in z^3.
 +
 +
==Notes and Code to Try==
 +
 +
<pre>
 +
// https://thecodest.co/blog/power-of-functional-programming-in-javascript-part-2-combinators/
 +
// combinators
 +
// function trains
 +
 +
//eval([COS,SIN,TAN,SUM].$fnx())(45)
 +
[COS,SIN,TAN,SUM].$fnx()
 +
[COS,SIN,TAN,SUM].$fnx()(45)
 +
[COS,SIN,TAN,SUM].$atop()(45)
 +
 +
[COS,SIN].$atop()
 +
 +
 +
[COS,SIN,TAN,SUM].$atop()(45)
 +
[COS,SIN,TAN,SUM].$atop()(22..45)
 +
[COS,SIN,TAN].$atop()(22..45)
 +
[SUM,[SIN,TAN]].$atop()(22..45)
 +
[[SIN,TAN],SUM].$atop()(22..45) // more like the way to operate
 +
 +
[[SIN,TAN],SUM].$fnx()(22..45)
 +
([[SIN,TAN],SUM].$fnx())+""
 +
 +
([[SIN,TAN],SUM].$fnx())(45..90)
 +
 +
([[[SIN],[TAN]],SUM].$fnx())(45..90)
 +
([[[SIN],[TAN]],SUM].$fnx())(49,39)
 +
([[[SIN],[TAN]],SUM].$fnx())(49,34)
 +
 +
([[[SIN],TAN],SUM].$fnx())(49,34)
 +
([[[SIN],TAN],SUM].$fnx())+""
 +
([[[SIN],TAN,[COS]],SUM].$fnx())+""
 +
([[[SIN],[TAN],[COS]],SUM].$fnx())+""
 +
([[SIN,TAN,[COS]],SUM].$fnx())+""
 +
 +
[DIVIDE,SUM,Length].$fork()
 +
 +
[DIVIDE,SUM,Length].$fork()(1..100)
 +
[DIVIDE,SUM,Length].$fork()([5, 3, 2, 8, 4, 2])
 +
 +
$Fork([DIVIDE,Length,SUM])([2,3,4,5])
 +
 +
[DIVIDE,SUM,Length].$fork()([5, 3, 2, 8, 4, 2])
 +
 +
[SIN,COS,TAN].$sequence()(1..10)
 +
// does not have to return values. just need to run them in sequence, no array result expected.
 +
// if needed, could have a wrap functionality to fnx with an array member doing that.
 +
 +
[SIN,COS,TAN].$pipe()(1..10)
 +
[SIN,COS,TAN].$compose()(1..10)
 +
 +
[SIN,COS,TAN].$tap()(1..10)
 +
// done: with itself call in parallel.
 +
// (function(a){return(ITSELF(TAN(COS(SIN(a)))))})
 +
// how to reflect ITSELF a in this. Maybe another indicator to capture and reflect?
 +
// and how do we wrap a set into an array?
 +
 +
[SIN,COS,TAN].$tap()(10)
 +
 +
[x=>x>4?1,x=>x>8?2,x=>x>14?3].$alternation()(10)
 +
 +
[x=>x>4?1,x=>x>8?2,x=>x>14?3].$alternation()(10)
 +
 +
[x=>x>4?1,x=>x>8?2,x=>x>14?3].$alternation()+""
 +
 +
[x=>x<4?1,x=>x<8?2,x=>x<14?3].$alternation()(10)
 +
 +
 +
[].$combinators()
 +
 +
 +
 +
[SIN,COS].$combinators("B")(3)
 +
[SIN,COS].$fnx("B")(3)
 +
 +
 +
[SIN,COS].$combinators("B")(3)
 +
[].$combinators("I")(3)
 +
[SIN,COS].$combinators("K")(3) // gives SIN as it ignore COS etc. constant
 +
[3,43].$combinators("K")
 +
 +
 +
[DIVIDE,SUM,Length].$combinators("Φ")(1..10)
 +
 +
// errors on this one because the com.
 +
[DIVIDE,SUM].$combinators("Σ")(1..10)
 +
 +
// not working. as a is not generating a function.
 +
//[SIN,COS].$combinators("Σ")(1..10)
 +
 +
[SIN,COS].$fnx("⊣⊢")(1..10)
 +
 +
[].$combinators()
 +
//add by default
 +
 +
window['λ⊣⊢']
 +
//can still work
 +
 +
 +
$combinators([SIN,COS],"B")(1..20)
 +
 +
[DIVIDE,SUM,Length].$combinators("B")(1..10) // gives error
 +
 +
</pre>
2,824

edits

Navigation menu