-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
The following is a proposal to extend Under (&.) to allow various (any, I hope) possible combinations.
Syntax
u&.(vi`v`ul`ur) y <--> {{vi v^:_1 ul u ur}} y
x u&.(vi`v`ul`ur) y <--> x {{vi v^:_1 ul u ur}} ywhere
u- verb to process transformed argument(s)v- verb with assigned obverse to do/undo arguments transformationvi- verb to produce a left argument forv^:_1, is[:ifv^:_1is monadicul- verb to produce a left argument foru, is[:ifuis monadicur- verb to produce a right argument foru
Model
und=: 2 : 'n@.0 n@.1^:_1 n@.2 u n@.3'Examples
Implement standard monadic &.:
%: <: *: 4 NB. sqrt(4^2 - 1)
3.87298
<:&.*: 4
3.87298
<: und ([:`*:`[:`*:) 4 NB. the resulting train is ([: *:^:_1 [: <: *:)
3.87298Implement standard dyadic &.:
%: (*: 3) + (*: 4) NB. sqrt(3^2 + 4^2)
5
3 +&.*: 4
5
3 + und ([:`*:`(*:@[)`(*:@])) 4 NB. the resulting train is ([: *:^:_1 *:@[ + *:@])
5Implement standard dyadic &. with semiduals:
%: 3 + (*: 4) NB. sqrt(3 + 4^2)
4.3589
3 +&.(a:`*:) 4
4.3589
3 + und ([:`*:`[`(*:@])) 4 NB. the resulting train is ([: *:^:_1 [ + *:@])
4.3589
%: (*: 3) + 4 NB. sqrt(3^2 + 4)
3.60555
3 +&.(*:`a:) 4
3.60555
3 + und ([:`*:`(*:@[)`]) 4 NB. the resulting train is ([: *:^:_1 *:@[ + ])
3.60555Implement non-standard monadic &. with dyadic inversion (say, for some J dictionary jdict):
upd=: get__jdict :. (put__jdict~)
NB. a monad to double values corresponding to keys y
+: und (]`upd`[:`upd) NB. the resulting train is (] upd^:_1 [: +: upd)Implement non-standard dyadic &. with dyadic inversion:
NB. a dyad which passes its left argument x to the left argument of v^:_1
u und ([`v`ul`ur) NB. the resulting train is ([ u^:_1 ul u ur)Implement an extension proposed in #212:
u und ([:`(m&{)`(m&{@[)`(m&{@])) NB. the resulting train is ([: m&{^:_1 m&{@[ + m&{@])Use extrinsic ul and ur not related to v at all:
u und (vi`v`f`g) NB. the resulting train is (vi v^:_1 f u g)Notes
Whether the u, v, v^:_1 verbs need to be ambivalent depends on the train to compose.
Metadata
Metadata
Assignees
Labels
No labels