Since I put Exercise 8 in the wrong thread I am reproducing it here:
Exercise 8. Rewrite the verb explicit verb ms shown below tacitly, as
usual, bonus points for a fixed tacit version (see the message [0]).
Mn=: 13 :'y H.(-x+1e_7)2'"1
M=: 13 :'|:y Mn 1 2 3,&>/-i.1+y'
ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
3":(i.@>:,ms) 10
A (wicked) solution follows after the warning.
[0] [Jprogramming] Using the hypergeometric adverb (H.).
http://www.jsoftware.com/pipermail/programming/2016-July/045466.html
_|_|_| _| _|
_| _|_|_| _|_| _| _|_| _| _|_|
_|_| _| _| _| _| _| _| _|_|_|_| _|_|
_| _| _| _| _| _| _| _| _|
_|_|_| _|_|_| _|_| _| _| _|_|_| _| _| _| _|
_|
_|
The following is a slightly edited session:
JVERSION
Engine: j805/j64/windows
Beta-9: commercial/2016-07-05T15:45:22
Library: 8.04.15
Qt IDE: 1.4.10/5.4.2
Platform: Win 64
Installer: J804 install
InstallPath: j:/program files/j
Contact: www.jsoftware.com
First, the explicit version,
Mn=: 13 :'y H.(-x+1e_7)2'"1
M=: 13 :'|:y Mn 1 2 3,&>/-i.1+y'
ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
3":(i.@>:,ms) 10
0 1 2 3 4 5 6 7 8 9 10
0 0 0 1 1 2 3 4 5 7 9
0 0 1 1 1 1 2 2 2 2 1
Next, the tacit (fixed) version.
Running the J Wicket Toolkit (see the trailing message),
(0!:0)<'/.../j wicked toolkit.ijs'
which is need it to define Mnt,
Mnt=. (] train@:((an 2) ;~ Cloak <'H.')f. (-@:(1e_7 + [)))"1
Mt=. |:@:(Mnt 1 2 3 ,&>/ -@:i.@:>:)
mst=. (<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 Mt f.)
3":(i.@>:,mst) 10
0 1 2 3 4 5 6 7 8 9 10
0 0 0 1 1 2 3 4 5 7 9
0 0 1 1 1 1 2 2 2 2 1
NB. It is fixed...
66 (-@:[ ]\ 5!:5@<@:]) 'mst'
(<:@:[ ,: %:@:([ * +:@:] - >:@:[))/@:|:@:(2 %~/\"1 |:@:(((] ,^:(0:
``:)&6 :.(<@:((,'0') ,&< ]))@:((<(,'0');2) ;~ ,^:(0:`H.)) -@:(9.99
99999999999995e_8 + [))"1) (1 2 3 ,&>/ -@:i.@:>:)))
(3":(i.@>:,ms) 100) -: (3":(i.@>:,mst) 100)
1
On Fri, Dec 18, 2015 at 7:33 PM, Jose Mario Quintana
<jose.mario.quintana at gmail.com
<http://jsoftware.com/mailman/listinfo/programming>> wrote:
>* Dan wrote:
*>>* At some point we’re going to have to put our heads together and create a
*>* JAL addon to collect all these utilities.
*>>* "So much to do, so little time." However, my current writing style might
*>* be perceived by many as nasty. A sample follows together with an updated
*>* Wicked Tacit Toolkit (WTT) that must be pre-loaded.
*>>* WARNING: The following is not for the faint-hearted :)
*>>*
http://www.collinsdictionary.com/dictionary/english/not-for-the-faint-hearted
<http://www.collinsdictionary.com/dictionary/english/not-for-the-faint-hearted>
*>>* Fetch, From, Left and Right are among some added adverbs to the WTT which
*>* I find useful. What do they do?
*>>* From produces a related list of boxed verbs,
*>>* 3 From
*>* ┌───┬───┬───┐
*>* │0&{│1&{│2&{│
*>* └───┴───┴───┘
*>* _5 From
*>* ┌────┬────┬────┬────┬────┐
*>* │_5&{│_4&{│_3&{│_2&{│_1&{│
*>* └────┴────┴────┴────┴────┘
*>>* Similiarly,
*>>* _3 Fetch
*>* ┌────────┬────────┬────────┐
*>* │_3&({::)│_2&({::)│_1&({::)│
*>* └────────┴────────┴────────┘
*>* 5 Fetch
*>* ┌───────┬───────┬───────┬───────┬───────┐
*>* │0&({::)│1&({::)│2&({::)│3&({::)│4&({::)│
*>* └───────┴───────┴───────┴───────┴───────┘
*>>* Left and Right select arguments accordingly,
*>>* 2 Fetch Right
*>* ┌──────────┬──────────┐
*>* │0&({::)@:]│1&({::)@:]│
*>* └──────────┴──────────┘
*>* _3 From Left
*>* ┌───────┬───────┬───────┐
*>* │_3&{@:[│_2&{@:[│_1&{@:[│
*>* └───────┴───────┴───────┘
*>>* When can they be useful?
*>>* This is an illustration (rewriting sf1 adverb in the original thread),
*>>* 'V0 V1 V2' =. 3 Fetch Right
*>* fg=. (0;1)&{:: NB. Fetching the gerund
*>* sf1=. ((;:'@{}') train o ((V0 at [cv) ; V1 ; (V2 at ]cv))&:box fg) o
*>* tie&'' f.adv
*>>* _66 ]\ (5!:5)@< 'sf1'
*>* ("_)(((`'')(&(((;:'@{}') ,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:((0&(
*>* {::)@:] ,^:(0:`@:) >@:((<[)"_)) ; 1&({::)@:] ; 2&({::)@:] ,^:(0:`@
*>* :) >@:((<])"_))&:(<@:(,^:(0:``:)&6 :.(<@:((,'0') ,&< ])))"0) (0;1)
*>* &({::))@:(,^:(0:``))&''@:(,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:(<@:
*>* ((0;1;0)&({::))))@:[)))((`_)(`:6)))
*>>* NB. Testing...
*>>* (v0 v1 v2)sf1
*>* v0@:[ v1 v2@:]
*>* ┌─────────┬──┬─────────┐
*>* │┌──┬──┬─┐│v1│┌──┬──┬─┐│
*>* ││v0│@:│[││ ││v2│@:│]││
*>* │└──┴──┴─┘│ │└──┴──┴─┘│
*>* └─────────┴──┴─────────┘
*>>* 3 4 (+: + -:)sf1 2 4
*>* 7 10
*>>* This is another version that might look a little less unfamiliar,
*>>* NB. Defining the darkhorse...
*>>* 'ATOP LEFT RIGHT'=. 3 From Left
*>* 'V0 V1 V2' =. 3 From Right
*>>* fg=. (0;1)&{:: NB. Fetching the gerund
*>* workhorse=. (;:'@[]') (V0 , ATOP , LEFT , V1 , V2 , ATOP , RIGHT c) fg
*>* darkhorse=. train o workhorse o tie&''
*>>* NB. Defining the adverb...
*>>* sf1=. darkhorse f.adv
*>>* _66 ]\ (5!:5)@< 'sf1'
*>* ("_)(((`'')(&(,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:((;:'@[]') (0&{@
*>* :] , 0&{@:[ , 1&{@:[ , 1&{@:] , 2&{@:] , 0&{@:[ , 2&{@:["_) (0;1)&
*>* ({::))@:(,^:(0:``))&''@:(,^:(0:``:)&6 :.(<@:((,'0') ,&< ]))@:(<@:(
*>* (0;1;0)&({::))))@:[)))((`_)(`:6)))
*>>* NB. Testing...
*>>* (v0 v1 v2)sf1
*>* v0@[ v1 v2@]
*>* ┌────────┬──┬────────┐
*>* │┌──┬─┬─┐│v1│┌──┬─┬─┐│
*>* ││v0│@│[││ ││v2│@│]││
*>* │└──┴─┴─┘│ │└──┴─┴─┘│
*>* └────────┴──┴────────┘
*>>* 3 4 (+: + -:)sf1 2 4
*>* 7 10
*>>>* The updated WTT follows (as always, beware of wrapping lines),
*>>>* NB.
*>* ----------------------------------------------------------------------------
*>* NB. Wicked Tacit Toolkit...
*>* NB.
*>* ----------------------------------------------------------------------------
*>>* NB. Load it using 0!:0 or similar or
*>* NB. paste it on an J editing window and use Crtl-A Crtl-E or
*>* NB. of course, load it using a hot key (or replace '=.' by '=:' if you
*>* must)
*>>* NB. A word is a noun, verb, adverb or conjunction
*>>>* (_ o=. @:) (c=. "_) (e=. &.>) (x=. @:[) (y=. @])
*>>* an=. <@:((,'0') ,&< ]) NB. Atomizing words (monadic verb)
*>>* Cloak=. (0:`)(,^:) NB. Cloaking (the
*>* atomic representations of)
*>* NB. adverbs or conjunctions as monadic or
*>* NB. dyadic verbs (adv)
*>* Cloak=. ((5!:1)@:<'Cloak')Cloak NB. Cloak verbing itself! (monadic ver)
*>>* 'amper at evoke fix rank tie'=. Cloak o < e o ;: '& @: `: f. " `'
*>* NB. Verbing some adverbs and conjunctions
*>>* train=. (evoke&6) :. an f. NB. (`:6) with a convenient obverse
*>* NB. (monadic verb)
*>* box=. (< o train "0) f. NB. Boxing primitives and pro-words
*>* NB. (monadic verb)
*>>* af=. an o fix
*>>* (a0=. `'') (a1=. (@:[) ((<'&')`) (`:6)) (a2=. (`(<(":0);_)) (`:6))
*>* av=. ((af'a0')`) (`(af'a1')) (`(af'a2') ) (`:6)
*>* NB. Adverbing a monadic verb (adv)
*>* assert 1 4 9 -: 1 2 3 *: adv
*>>* aw=. < o ((0;1;0)&{::) NB. Fetching the atomic representation
*>>* u (a3=. (o (train o aw f.)) ('av'f.)) (a4=. "_)
*>>* adv=. train o ((af'a4') ; ] ; (af'a3')"_) f.av
*>* assert 1 4 9 -: 1 2 3 *: adv
*>* assert 6 -: * (,^:(0:`(<'/'))) adv 1 2 3
*>* assert 0 1 3 -: (*:`(+/\)) (train f. o (0&{ , (<'-') , 1&{)) adv 1 2 3
*>>* a3=. (o (aw f.)) ('av'f.)
*>>* Adv=. (train f. @:) (train o ((af'a4') ; ] ; (af'a3')"_) f.av)
*>* assert 1 4 9 -: 1 2 3 ((<'*:') ; ] ) Adv
*>* assert 6 -: * (< , ((<'/')"_)) Adv 1 2 3
*>* assert 0 1 3 -: (*:`(+/\)) (0&{ , (<'-') , 1&{)@:(('';1)&{::) Adv 1 2 3
*>>* Ver=. Cloak o af f. NB. Verbing after fixing a pro-adverb or
*>* pro-conjunction
*>* NB. (monadic verb)
*>* ver=. Cloak o an f. NB. Verbing after fixing an adverb or conjunction
*>* NB. (monadic verb)
*>>* NB. Defining cv in terms of itself...
*>* cv=. ((rank&_) o < o train)f.adv (>@:) NB. First version
*>* cv=. (train f. cv at (<x rank _ c)) f.adv NB. Constant verb
*>* u ( cv=. ( >cv at (<x rank _ c)) f.adv )
*>* NB. Constant word (adv)
*>* NB. (cv is to words as c is to nouns)
*>* assert (CRLF cv _) -: CRLF
*>* assert (u cv _) <adv -: u <adv
*>* assert (!@# cv _) <adv -: !@# <adv
*>* assert (< o ((Ver'cv') o train <'/') _) -: ( < o train (<'/'))
*>* assert (< o ((Ver'cv') o train <'"') _) -: ( < o train (<'"'))
*>>>* NB. Fetch and From...
*>* pointers=. (<: o - o i.)`i. @.(0<])
*>>* Fetch=. (] amper {:: cv)e o pointers f.adv NB. Verbs mnemonics pointers
*>* NB. (e.g., ( 'u0 u1 u2 u3'=. 4 Fetch ) j ( 'v0 v1 v2 v3'=. _4 Fetch ) )
*>>* assert (< o train 3 Fetch) -: ( 0&({::) 1&({::) 2&({::)) (< adv)
*>* assert (< o train _3 Fetch) -: (_3&({::) _2&({::) _1&({::)) (< adv)
*>>* From=. (] amper { cv)e o pointers f.adv NB. Verbs mnemonics pointers
*>* NB. From=. (] ([ amper train y)(({ `'')c))e o i. f. adv
*>* NB. (e.g., ( 'u0 u1 u2 u3'=. 4 From ) j ( 'v0 v1 v2 v3'=. _4 From ) )
*>>* assert (< o train 3 From ) -: ( 0&{ 1&{ 2&{ ) (<adv)
*>* assert (< o train _3 From ) -: (_3&{ _2&{ _1&{ ) (<adv)
*>>* Left=. (at [cv)e f.adv
*>* Right=. (at ]cv)e f.adv
*>>>* On Tue, Dec 15, 2015 at 6:47 PM, Dan Bron <j at bron.us
<http://jsoftware.com/mailman/listinfo/programming>> wrote:
*>>>* > Against my best judgement :), a purist version of Adv follows,
*>>* > assert 1 4 9 -: 1 2 3 *: av
*>>>>* That’s so cool :)
*>>>>* At some point we’re going to have to put our heads together and create a
*>>* JAL addon to collect all these utilities.
*>>>>* Named F^4, of course.
*>>>>* -Dan
*
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm