Partial function application: Difference between revisions

(add scala)
Line 90:
fsf2 fsf1 1+i.4
4 16 36 64</lang>
 
That said, note that much of this is unnecessary, since f1 and f2 already work the same way on list arguments.
 
<lang j> f1 i.4
0 2 4 6
f2 i.4
0 1 4 9
f1 1+i.4
2 4 6 8
f2 f1 1+i.4
4 16 36 64</lang>
 
That said, note that if we complicated the definitions of f1 and f2, so that they would not work on lists, the fs approach would still work:
 
In other words, given:
 
<lang j>crippled=:1 :0
assert.1=#y
u y
)
 
F1=: f1 crippled
F2=: f2 crippled
fsF1=: F1 fs
fsF2=: F2 fs</lang>
 
the system behaves like this:
 
<lang j> F1 i.4
|assertion failure: F1
| 1=#y
fsF1 i.4
0 2 4 6
NB. and so on...</lang>
 
=={{header|OCaml}}==
6,962

edits