> On 16 May 2016, at 4:05 AM, Jose Mario Quintana 
> <[email protected]> wrote:
> 
> Solutions to Exercises 4 and 5 follow after the warning...
> 
>  ___                _   _
> / __|  _ __   ___  (_) | |  ___   _ _   ___
> \__ \ | '_ \ / _ \ | | | | / -_) | '_| (_-<  _   _   _
> |___/ | .__/ \___/ |_| |_| \___| |_|   /__/ (_) (_) (_)
>       |_|
> 
> 
> 
> 
> 
> 
> 
> Exercise 4.
> 
> Pascal wrote:
> 
>  a4 =: 1 : 'u' is pretty hard to beat.  semi-tacit: return value is tacit.
> 
> 
> Right, something that is so simple to accomplish explicitly it is difficult
> to do tacitly...  Unless one has access to the right tools (see reference
> [0] near the end of the trailing post(s)):
> 
> Using hg,
> 
>   a4=. ]hg
> 
> Using adv,
> 
>   a4=. ]adv
> 
> Exercise 5.
> 
> The natural explicit solution is,
> 
>   a5=. 1 : '<u'
> 
>   1 2 3 a5
> ┌─────┐
> │1 2 3│
> └─────┘
> 
> Its tacit counterpart (using adv) is,
> 
>   a5=. <adv
> 
>   1 2 3 a5
> ┌─────┐
> │1 2 3│
> └─────┘
> 
> However, they are not exactly equivalent.  This tacit version of a5 is
> wicked and can also box verbs, for instance,
> 
>   ^&* a5
> ┌───┐
> │^&*│
> └───┘
> 
> instead of producing hooks as the explicit version does.
> 
> Why would one want to box verbs?  Among other things, to pass them as
> arguments to other verbs!
> 
> 
> 
> On Sun, Apr 24, 2016 at 9:27 PM, 'Pascal Jasmin' via Programming <
> [email protected]> wrote:
> 
>> As usual I'm discussing solutions below
>> .
>> .
>> .
>> .
>> .
>> 
>> .
>> .
>> .
>> .
>> .
>> 
>> 
>> a4 =: 1 : 'u' is pretty hard to beat.  semi-tacit: return value is tacit.
>> 
>> 
>> without going wicked, this is close, but only works for non nouns.
>> 
>> a4 =: (`'') (`:6)
>> 
>> this seems like a reasonable cheat
>> 
>> ("_ )(`'' )(`:6)
>> 
>> assuming a5 argument is a noun
>> 
>> a5 =: a4(<@:) V
>> 
>> where V cheats:
>> 
>> 
>> V =: 1 : 'u i.0'
>> 
>> a6 is a bit ambiguous if your example uses a u that returns nothing or y.
>> 
>> very interested in a7.
>> 
>> 
>> 
>> 
>> ----- Original Message -----
>> From: Jose Mario Quintana <[email protected]>
>> To: Programming forum <[email protected]>
>> Sent: Sunday, April 24, 2016 7:54 PM
>> Subject: Re: [Jprogramming] Adverbial Tacit Jym
>> 
>> Now that the first round of exercises are almost out of the way we can
>> entertain some utility adverbs.
>> 
>> This round is open in the sense that explicit adverbs are also allowed as
>> solutions; but, of course, tacit solutions would be better and fixed tacit
>> solutions would be the best ;)
>> 
>> 
>> Exercise 4.  Produce the Golden Age Identity adverb a4 (Id): "]: is the
>> identity adverb, that yields its argument."  For example,
>> 
>>   Id=. 'a4'f.
>> 
>>     1 2 3 Id
>> 1 2 3
>>     *     Id
>> *
>>   1 2 3 * Id 4 5 6
>> 4 10 18
>> 
>>  Hint: It is easy using hg or adv.
>> 
>> 
>> Exercise 5.  Produce the adverb a5 that yields its argument boxed.  For
>> example,
>> 
>>   (i.2 3) a5
>> ┌─────┐
>> │0 1 2│
>> │3 4 5│
>> └─────┘
>> 
>>  Hint: It is easy using adv.
>> 
>> 
>> Exercise 6.  Let us assume that u is an arbitrary monadic verb which is
>> expensive to compute.  Produce a6 such that  (u a6)Y -: (u ("_1))Y  but  u
>> a6  does not repeat the computation of the same items of Y.  For example,
>> 
>>   cheap=. 'a6'f.
>> 
>>   delay=. 6!:3
>>   timer=. 6!:2
>> 
>>   timer'delay ("_1) (5$%:2)'
>> 7.07262802
>>   timer'delay cheap (5$%:2)'
>> 1.41460927
>> 
>>   (delay cheap -: delay ("_1)) (5$%:2)
>> 1
>> 
>>   (([echo) o (+/) cheap ; +/ ("_1))4 3 2 $ i.4
>> 2 5
>> 4 7
>> ┌───┬───┐
>> │2 5│2 5│
>> │4 7│4 7│
>> │2 5│2 5│
>> │4 7│4 7│
>> └───┴───┘
>> 
>> 
>> Exercise 7.  Produce the adverbs a7x0 and a7x1 that provide respectively
>> monadic and dyadic recursion scope to a tacit verb denoted by the self
>> reference verb ($:) yielding another tacit verb (a wicked verb, if
>> necessary).  For example,
>> 
>>   mRS=. 'a7x0'f.  NB. Monadic recursive scope
>>   dRS=. 'a7x1'f.  NB. Dyadic  recursive scope
>> 
>>   fac=. 1:`(] * $:@:<:)@.*
>>   (1 + fac f.mRS)5
>> 121
>> 
>>   binomial=. 1:`(%~ * $:&:<:)@.(*@:[)
>>   3 (1 + binomial f.dRS) 7
>> 36
>> 
>> Hint: My solutions are wicked.
>> 
>> 
>> 
>> On Sun, Mar 13, 2016 at 10:59 PM, Jose Mario Quintana <
>> [email protected]> wrote:
>> 
>>> Welcome to the Adverbial (and Conjunctional) Tacit Jymnasium :)
>>> 
>>> Orthodox and wicked routines will be practiced here for those interested
>>> in developing adverbial (and conjunctional) tacit muscles.  Official
>>> interpreters will be the standard equipment; however, Unbox, Jx, and
>> other
>>> J interpreters (including Golden Age J interpreters), as well as
>> Toolkits ,
>>> see for example [0], and alike (e.g., the tacit translator), are in
>> general
>>> more than acceptable although occasionally some restrictions might be
>>> imposed aiming to develop certain muscles.  Since adverbial (and
>>> conjunctional) tacit writing can (following two closely related
>> approaches)
>>> be reduced to verbal tacit writing, this is also a place to exercise
>> verbal
>>> tacit muscles.  In addition, some adverbs (and conjunctions) which will
>> be
>>> eventually shown here can provide general support for producing tacit
>>> verbs, adverbs and conjunctions.
>>> 
>>> Instructors will describe an exercise and, unless otherwise specified in
>>> advance, will be prepared to show at least one way to perform it if
>> patrons
>>> (including other instructors) have not performed the exercise after a
>>> reasonable time; alright, they have bragging rights either way ;)  The
>>> exercises would typically involve producing adverbs with bonus points for
>>> producing fixed versions of the adverbs and their products.  Exercises
>> are
>>> not required to be brand new.  Given credit to the originators of certain
>>> techniques is not necessary (but you know who you are and bragging is
>>> allowed).  Spoiler alerts by instructors and patrons will be appreciated.
>>> 
>>> Instructors (Dan, Thomas et al. are you listening?), not to mention
>>> patrons (including beginners), are all very welcome here.  How long will
>>> the Jym remain open?  Indefinitely, as long as there enough patrons and
>>> instructors or we are kicked out of here.
>>> 
>>> Let us start with a few exercises with different degrees of difficulty
>>> (feel free to ask any questions just be patient with me, sometimes I
>>> disappear for a few days):
>>> 
>>> 
>>> - Exercise 0.  Rank infinity
>>> 
>>> Produce a (tacit, of course) adverb  a0  such that  u a0  produces  u"_
>>> where u is a noun or a verb, for example,
>>> 
>>>   u a0
>>> u"_
>>> 
>>>   *:@:(+/) a0
>>> *:@:(+/)"_
>>> 
>>>   u=. 1 2 3
>>> 
>>>   u a0
>>> 1 2 3"_
>>> 
>>>   1 2 3 a0
>>> 1 2 3"_
>>> 
>>> 
>>> - Exercise 1.  Operating on the first and last items
>>> 
>>> Produce an adverb a1 such that  u a1 produces  {. u {:  where u is a
>> verb,
>>> for example,
>>> 
>>>   erase'u'
>>> 1
>>> 
>>>   u a1
>>> {. u {:
>>> 
>>>   * a1
>>> {. * {:
>>> 
>>>   * a1 2 3 5 7
>>> 14
>>> 
>>> 
>>> - Exercise 2. Back insert
>>> 
>>> Produce an adverb a2 which is a tacit counterpart of the explicit adverb
>>> rscan, see [1],
>>> 
>>>   rscan=. 1 : '((>: - m |&# y) |. m)/y'
>>> 
>>> for example,
>>> 
>>>   (+`%`*   rscan\. ,:  +`%`*   a2\.)  1 2 3 4 5 6 7
>>> 1.16184971 0.161849711 12.3571429 4.11904762 0.119047619 42 7
>>> 1.16184971 0.161849711 12.3571429 4.11904762 0.119047619 42 7
>>> 
>>>   (+`-`*`% rscan\. ,:  +`-`*`% a2\.)  1 2 3 4 5 6 7 8
>>> _0.6 1.6 0.8 3.75 _0.25 5.25 0.875 8
>>> _0.6 1.6 0.8 3.75 _0.25 5.25 0.875 8
>>> 
>>> 
>>> - Exercise 3.  Replace items
>>> 
>>> Produce an adverb a3 which is a tacit counterpart of the explicit adverb
>>> ritem, see [2],
>>> 
>>> ritem =: 1 : (':' ; 'x (I.m-:"_1 _ y) } m')
>>> 
>>> for example,
>>> 
>>> C=. 3 4$i.8
>>> A=. i.3 2 4
>>> 
>>> assert 9 8 7 6 (C ritem -: C a3) 0 1 2 3
>>> assert (100%i.2 4) (A ritem -: A a3) 16+i.2 4
>>> 
>>> 
>>> References
>>> 
>>> [0] [Jprogramming] Tacit Toolkit (was dyadic J)
>>> 
>>> http://www.jsoftware.com/pipermail/programming/2015-December/043757.html
>>> 
>>> [1] [Jprogramming] Am I understanding m/y ?
>>> 
>>> http://www.jsoftware.com/pipermail/programming/2016-February/044483.html
>>> 
>>> [2] [Jprogramming] Replace Items
>>>   http://www.jsoftware.com/pipermail/programming/2016-March/044625.html
>>> 
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to