Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/First-class-functions/J/first-class-functions-1.j
Normal file
10
Task/First-class-functions/J/first-class-functions-1.j
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
sin=: 1&o.
|
||||
cos=: 2&o.
|
||||
cube=: ^&3
|
||||
square=: *:
|
||||
unqo=: `:6
|
||||
unqcol=: `:0
|
||||
quot=: 1 :'{.u`'''''
|
||||
A=: sin`cos`cube`square
|
||||
B=: monad def'y unqo inv quot'"0 A
|
||||
BA=. A dyad def'x unqo@(y unqo) quot'"0 B
|
||||
4
Task/First-class-functions/J/first-class-functions-2.j
Normal file
4
Task/First-class-functions/J/first-class-functions-2.j
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
A unqcol 0.5
|
||||
0.479426 0.877583 0.125 0.25
|
||||
BA unqcol 0.5
|
||||
0.5 0.5 0.5 0.5
|
||||
21
Task/First-class-functions/J/first-class-functions-3.j
Normal file
21
Task/First-class-functions/J/first-class-functions-3.j
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
train =. (<'`:')(0:`)(,^:)&6 NB. Producing the function train corresponding to the functional `:6
|
||||
inverse=. (<'^:')(0:`)(,^:)&_1 NB. Producing the function inverse corresponding to the functional ^:_1
|
||||
compose=. (<'@:')(0:`)(,^:) NB. Producing the function compose corresponding to the functional @:
|
||||
an =. <@:((,'0') ; ]) NB. Producing the atomic representation of a noun
|
||||
of =. train@:([ ; an) NB. Evaluating a function for an argument
|
||||
box =. < @: train"0 NB. Producing a boxed list of the trains of the components
|
||||
|
||||
]A =. box (1&o.)`(2&o.)`(^&3) NB. Producing a boxed list containing the Sin, Cos and Cubic functions
|
||||
┌────┬────┬───┐
|
||||
│1&o.│2&o.│^&3│
|
||||
└────┴────┴───┘
|
||||
]B =. inverse &.> A NB. Producing their inverses
|
||||
┌────────┬────────┬───────┐
|
||||
│1&o.^:_1│2&o.^:_1│^&3^:_1│
|
||||
└────────┴────────┴───────┘
|
||||
]BA=. B compose &.> A NB. Producing the compositions of the functions and their inverses
|
||||
┌────────────────┬────────────────┬──────────────┐
|
||||
│1&o.^:_1@:(1&o.)│2&o.^:_1@:(2&o.)│^&3^:_1@:(^&3)│
|
||||
└────────────────┴────────────────┴──────────────┘
|
||||
BA of &> 0.5 NB. Evaluating the compositions at 0.5
|
||||
0.5 0.5 0.5
|
||||
Loading…
Add table
Add a link
Reference in a new issue