Christopher McIntosh <thegeeko61 <at> gmail.com> writes:
>
> Ok. So here's my problem:
>
And here are 2 possible cases... both of which I find extraordinarily beautiful
examples... Thanks to the authors!
<---- EXAMPLE 1 : BEGIN ----------------------------------------------->
nlmonad =: [: cutopen_z_`(4!:1)@.(1 4 8 e.~ 3!:0) ((0 1 2 3"_)^:(0=#))
nldyad =: (4 :0 nlmonad)
nms=.y
if. #t=. x -. ' ' do.
'n s'=. '~*' e. t
t=. t -. '~*'
b=. t&E. &> nms
if. s do. b=. +./"1 b
else. b=. {."1 b end.
nms=. nms #~ n ~: b
end.
)
nl3 =: nlmonad : nldyad
<---- EXAMPLE 1 : END ------------------------------------------------->
<---- EXAMPLE 2 : BEGIN ----------------------------------------------->
NB.*nl v selective namelist
NB. Form: [mp] nl sel
NB.
NB. sel: one or more integer name classes, or a name list.
NB. if empty use: 0 1 2 3.
NB. mp: optional matching pattern. If mp contains '*', list names
NB. containing mp, otherwise list names starting mp. If mp
NB. contains '~', list names that do not match.
NB.
NB. e.g. 'f' nl 3 - list verbs that begin with 'f'
NB. '*com nl '' - list names containing 'com'
nl1=.(([:4!:1])&(]`(0 1 2 3"_)@.(0=#))) :: cutopen_z_
nlz=:(nl1 : ((4 : 0)nl1)) f.
if. 0 e. #y do. y return. end.
if. #t=. x -. ' ' do.
'n s'=. '~*' e. t
t=. t -. '~*'
b=. t&E. &> y
if. s do. b=. +./"1 b
else. b=. {."1 b end.
y=. y #~ n ~: b
end.
)
<---- EXAMPLE 2 : END ------------------------------------------------->
I have posted them here for others who may be interested in converting
explicitly-defined functions into tacitly-defined ones.
Here is the code for the explicitly-defined function:
<---- EXAMPLE 3 : BEGIN ----------------------------------------------->
nl=: 3 : 0
'' nl y
:
if. 0 e. #y do. y=. 0 1 2 3 end.
if. 1 4 8 e.~ 3!:0 y do.
nms=. (4!:1 y) -. ;: 'x y x. y.'
else.
nms=. cutopen_z_ y
end.
if. 0 e. #nms do. return. end.
if. #t=. x -. ' ' do.
'n s'=. '~*' e. t
t=. t -. '~*'
b=. t&E. &> nms
if. s do. b=. +./"1 b
else. b=. {."1 b end.
nms=. nms #~ n ~: b
end.
)
<---- EXAMPLE 3 : END ------------------------------------------------->
Wow! There is so much to learn from this exercise... Let me go have some fun
while I learn!...
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm