First-class functions: Difference between revisions

Line 1,400:
<lang j> 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
at compose=. (<'@:')(0:`)(,^:) NB. Producing the function at 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
Line 1,413:
│1&o.^:_1│2&o.^:_1│^&3^:_1│
└────────┴────────┴───────┘
]BA=. B atcompose &.> 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</lang>
</lang>
 
=={{header|Java}}==
Anonymous user