>Also, performance might, or might not, be an issue
> regarding your project which sounds quite interesting. How big are you
> expecting to be the gerunds involved? Can you describe the specific
> problem and outline the method for attacking it?
I wouldn't call my project interesting, because I'm really just playing around. 
Essentially trying to solve ODEsby returning the verb solution. And generally 
solving othe rproblems where the answer is a verb and not a noun.
Something I was splaying with at lunchtime today, integrating J verbs that fail 
with d. .e.g.integrate exp(x) * x^2.
(^**:) d. _1 
gives a domain error.
But...
NB. WARNING! EASY TO BLOW UP YOUR STACK IF YOU USE WRONG PARAMS!!!  NB. 
Essentially integration by parts.

INTEGRATE =: 2 : 0



if. ('"') = >0{,>(v`'') do.



(u d. _1)* v



else.



(( u d. _1) * v) -  ((u d. _1) INTEGRATE (v d. 1))



end.

)


works... ...sometimes.
e.g.^ INTEGRATE (*:)
gives:   
(^ * *:) - (^ * +:) - ^ * 2"0


So if I want to integrate (or more correctly, calculate the antiderivative of) 
cos(x)*x^3


I can do


(2&o.) INTEGRATE (^&3)   
which gives


(1&o. * ^&3) - (-@(2&o.) * 3&*@(^&2)) - (-@(1&o.) * 0 6x&p.) - -@(-@(2&o.)) * 
6x"0




which is almost unreadable, but I think correct (tested with Wolfram Alpha - 
I'm too lazy to try it with pen and paper).


The right variable must eventually reach a constant when differentiated 
repeatedly. And the left variable must be chosen carefully. Log fails (^.), for 
example.


And I'm trying to write a conjunction that will solve a linear ODE of any 
order, with boundary conditions.  I'm really just playing around with J. Not 
using it for serious stuff.


Jon




> Date: Thu, 23 Apr 2015 18:14:06 -0400
> From: [email protected]
> To: [email protected]
> Subject: Re: [Jprogramming] Evaluating a Gerund Array
> 
> No worries Jon,  I also take my time ;)  I was just making the point
> (showing off) that with a suitable interpreter and set of utilities solving
> these kind of meta-programming problems is relatively easy. So, cv, Train,
> conj,... and g were loaded utilities whose definitions were not shown (g is
> just a pro-adverb for ("0)).
> Jx refers to an J interpreter with some extensions [0] (see the explanation
> therein).
> 
> The following seems to be a fairly general and straightforward (brute
> force) orthodox way to deal with your last task and other similar problems:
> 
>    plus=. 4 : 0
>    u=. x`:6
>    v=. y`:6
>   (u + v)`''
> )
> 
> 
>    ata=. 4 : 0
>    v=. x`:6
>    N=. y
>   (N&*@:v)`''
> )
> 
>    cnj=. 2 : 0
>   ( x plus/ .(ata"0) y)`:6
> )
> 
>    (*:`+:`^) cnj 3 4 5
> 3&*@:*: + 4&*@:+: + 5&*@:^
> 
> 
>    (*:`+:`^) cnj 3 4 5 (1 2 3)
> 24.5914 64.9453 151.428
> 
> Just do not ask me how it works; explicit writing is not my ally and I
> cannot wait to be back to my comfort zone.  However, you might find debug
> and dissect helpful.  Also, performance might, or might not, be an issue
> regarding your project which sounds quite interesting.  How big are you
> expecting to be the gerunds involved?  Can you describe the specific
> problem and outline the method for attacking it?
> 
> [0] [Jprogramming] J functional programming extensions
>      http://www.jsoftware.com/pipermail/programming/2013-March/031835.html
> 
> 
> 
> 
> 
> On Wed, Apr 22, 2015 at 12:49 PM, Jon Hough <[email protected]> wrote:
> 
> > Hi Pepe,
> > Please don't think I'm ignoring this. I'm very slowly reading through it.
> > In fact, I went back to Raul's long answer and am trying to understand it
> > completely.
> > I am starting to understand the way in which gerunds are stored/parsed. I
> > made my own verb (which is essentially the same as Raul's).
> > gerund =: *:`+:`*:`^.`-:
> > insert =:  <@:([ , (('+'&;)@:]))
> >
> >
> > (insert/ gerund)`:6
> >
> >
> > which will input the pluses between the verbs in the gerund box. This part
> > I get. (Of course, this doesn't solve the constant multiplication part of
> > the problem). This is as far as my brain has got on this.
> >
> >
> > So I'm reading through all this quite slowly.
> >
> >
> > By the way, I don't know what "g" is in this expression:
> >
> >
> >
> >
> > (*:`%: ,. +:`^) [: [ an y Train g f. 1 2
> >
> >
> > It isn't defined anywhere it seems. I'm also not sure what Jx is.
> > Presumably this is the extended J you mentioned. Is this an Open Source
> > project?
> >
> >
> >
> >
> > Jon
> >
> > > Date: Tue, 21 Apr 2015 19:33:01 -0400
> > > From: [email protected]
> > > To: [email protected]
> > > Subject: Re: [Jprogramming] Evaluating a Gerund Array
> > >
> > > " I will try to outline it after work if I have a chance."
> > >
> > > Jon, yesterday I did not have a chance but today I had (more or less).
> > > Before I start with the outline of the other method let me to quickly
> > > review my preferred (tacit) method which I find quite powerful and
> > > enjoyable.  To put it in perspective, I solved the problems that you
> > posed
> > > roughly as follows:
> > >
> > > I launched the latest Jx  interpreter, I clicked a user-defined key to
> > load
> > > my standard utility set, and then all that was required to type was the
> > > following (again this, and what follows, is copied from the execution
> > > window and pasted here),
> > >
> > >    NB. First...
> > >
> > >    (*:`%: ,. +:`^) [: [ an y Train g f. 1 2
> > >          1         2
> > > 1.41421356 7.3890561
> > >
> > >    NB. Second...
> > >
> > >    plus=. [: [ +cv ] Train
> > >    ata=. (] amper *cv) at [
> > >
> > >    cnj=. > o (box x (< o plus/ .(ata e)) ]) f.conj
> > >    type'cnj'
> > > ┌───────────┐
> > > │conjunction│
> > > └───────────┘
> > >
> > >    (*:`+:`^) cnj 3 4 5
> > > 3&*@:*: + 4&*@:+: + 5&*@:^
> > >    (*:`+:`^) cnj 3 4 5 (1 2 3)
> > > 24.5914091 64.9452805 151.427685
> > >
> > > Sure, I had the benefit of having solved similar cases before, I had to
> > > correct some typos, and maybe I tried a couple of times before I got it
> > > right.  That was the easy part; the hard (time consuming) part was, by
> > far,
> > > rewriting the script to be able to run it, from scratch, using an
> > official
> > > interpreter, adding commentary, finding some references, and wrestling
> > with
> > > the EOLs.
> > >
> > > This method, or style, works by verbalizing the primitive (or other)
> > > adverbs and conjunctions and feeding those verbs with nouns and verbs
> > > directly (or even adverbs and conjunctions indirectly) to produce tacitly
> > > nouns or verbs (or even adverbs and conjunctions) as needed.  A utility
> > > verb (box) takes a gerund and produces corresponding array of boxed words
> > > (nouns, verbs, adverbs and conjunctions) to be able deal with them.
> > >
> > > Efficiency aside, this method can be replicated, in principle, by taking
> > > the atomic representations (or similar) of the words to produce
> > explicitly
> > > atomic representations of the desired words as needed (if the aim is to
> > > produce a word then train (`:6) can do the honors).  The main issue with
> > > this approach, as you and others (myself included) have found, is dealing
> > > with atomic representations, gerunds, etc.
> > >
> > > In my experience a major stumbling block is finding an atomic, gerundial
> > or
> > > similar representation, amenable for use with train (`:6), as a function
> > of
> > > some of its components.  For example, just for the sake of the argument,
> > > assume that one wants write the verb (just2) such that (in particular),
> > >
> > >     ((*:`+:) just2R (3 4)) `:6
> > > 3&*@:*: + 4&*@:+:
> > >
> > > and in general ((v0`v1) just2 (N0,N1)) `:6 would produce N0&*@:v0 +
> > > N1&*@:v1 for any (suitable and specific) arguments.   In other words we
> > > want to atomize, so to speak, the sentence (N0&*@:v0 + N1&*@:v1).
> > > Fortunately for the rest of us Dan has written [0] the components
> > (nest2Box
> > > and gTxt) needed to define,
> > >
> > >    NB. Atomizing a sentence from its linear representation...
> > >    as=. ({::L:0 _~ nest2Box) o gTxt f.
> > >
> > > which allows one to write (please be gentle, I am allergic to writing
> > > explicitly; I was bitten too many times) ,
> > >
> > >    just2R=. 4 : 0
> > >   'N0 N1'=. y
> > >   (v0=. (0{x)`:6) (v1=. (1{x)`:6)
> > >
> > >   y=. (as'N0&*@:(v0 f.) + N1&*@:(v1 f.)')`:6
> > >
> > >   5!:1@<'y'
> > > )
> > >
> > >     (*:`+:) just2R (3 4)
> > > ┌───────────────────────────────────────────────────────┐
> > > │┌─┬───────────────────────────────────────────────────┐│
> > > ││3│┌───────────────────────┬─┬───────────────────────┐││
> > > ││ ││┌──┬──────────────────┐│+│┌──┬──────────────────┐│││
> > > ││ │││@:│┌─────────────┬──┐││ ││@:│┌─────────────┬──┐││││
> > > ││ │││  ││┌─┬─────────┐│*:│││ ││  ││┌─┬─────────┐│+:│││││
> > > ││ │││  │││&│┌─────┬─┐││  │││ ││  │││&│┌─────┬─┐││  │││││
> > > ││ │││  │││ ││┌─┬─┐│*│││  │││ ││  │││ ││┌─┬─┐│*│││  │││││
> > > ││ │││  │││ │││0│3││ │││  │││ ││  │││ │││0│4││ │││  │││││
> > > ││ │││  │││ ││└─┴─┘│ │││  │││ ││  │││ ││└─┴─┘│ │││  │││││
> > > ││ │││  │││ │└─────┴─┘││  │││ ││  │││ │└─────┴─┘││  │││││
> > > ││ │││  ││└─┴─────────┘│  │││ ││  ││└─┴─────────┘│  │││││
> > > ││ │││  │└─────────────┴──┘││ ││  │└─────────────┴──┘││││
> > > ││ ││└──┴──────────────────┘│ │└──┴──────────────────┘│││
> > > ││ │└───────────────────────┴─┴───────────────────────┘││
> > > │└─┴───────────────────────────────────────────────────┘│
> > > └───────────────────────────────────────────────────────┘
> > >
> > >    ((*:`+:) just2R (3 4))`:6
> > > 3&*@:*: + 4&*@:+:
> > >
> > > Of course, for the problem that you posed, this approach would not be
> > > sufficient.  However, one can now write the counterparts of the verbs
> > plus
> > > and ata relatively in a straightforward manner,
> > >
> > > First, plus,
> > >
> > >    plusR=. 4 : 0
> > >   u=. x`:6
> > >   v=. y`:6
> > >
> > >   y=. (as'u f. + v f.')`:6
> > >   5!:1@<'y'
> > > )
> > >
> > >     ((3&*@:*:)`'') plusR ((4&*@:+:)`'')
> > > ┌───────────────────────────────────────────────────────┐
> > > │┌─┬───────────────────────────────────────────────────┐│
> > > ││3│┌───────────────────────┬─┬───────────────────────┐││
> > > ││ ││┌──┬──────────────────┐│+│┌──┬──────────────────┐│││
> > > ││ │││@:│┌─────────────┬──┐││ ││@:│┌─────────────┬──┐││││
> > > ││ │││  ││┌─┬─────────┐│*:│││ ││  ││┌─┬─────────┐│+:│││││
> > > ││ │││  │││&│┌─────┬─┐││  │││ ││  │││&│┌─────┬─┐││  │││││
> > > ││ │││  │││ ││┌─┬─┐│*│││  │││ ││  │││ ││┌─┬─┐│*│││  │││││
> > > ││ │││  │││ │││0│3││ │││  │││ ││  │││ │││0│4││ │││  │││││
> > > ││ │││  │││ ││└─┴─┘│ │││  │││ ││  │││ ││└─┴─┘│ │││  │││││
> > > ││ │││  │││ │└─────┴─┘││  │││ ││  │││ │└─────┴─┘││  │││││
> > > ││ │││  ││└─┴─────────┘│  │││ ││  ││└─┴─────────┘│  │││││
> > > ││ │││  │└─────────────┴──┘││ ││  │└─────────────┴──┘││││
> > > ││ ││└──┴──────────────────┘│ │└──┴──────────────────┘│││
> > > ││ │└───────────────────────┴─┴───────────────────────┘││
> > > │└─┴───────────────────────────────────────────────────┘│
> > > └───────────────────────────────────────────────────────┘
> > >
> > >    (((3&*@:*:)`'') plusR ((4&*@:+:)`''))`:6
> > > 3&*@:*: + 4&*@:+:
> > >
> > > One can now produce, for example,
> > >
> > >     plusR/ (3&*@:*:)`(4&*@:+:)`(5&*@:^)
> > >
> > ┌──────────────────────────────────────────────────────────────────────────────────────┐
> > >
> > │┌─┬──────────────────────────────────────────────────────────────────────────────────┐│
> > >
> > ││3│┌───────────────────────┬─┬──────────────────────────────────────────────────────┐││
> > > ││
> > >
> > ││┌──┬──────────────────┐│+│┌─┬──────────────────────────────────────────────────┐│││
> > > ││ │││@:│┌─────────────┬──┐││
> > > ││3│┌───────────────────────┬─┬──────────────────────┐││││
> > > ││ │││  ││┌─┬─────────┐│*:│││ ││
> > > ││┌──┬──────────────────┐│+│┌──┬─────────────────┐│││││
> > > ││ │││  │││&│┌─────┬─┐││  │││ ││ │││@:│┌─────────────┬──┐││
> > > ││@:│┌─────────────┬─┐││││││
> > > ││ │││  │││ ││┌─┬─┐│*│││  │││ ││ │││  ││┌─┬─────────┐│+:│││ ││
> > >  ││┌─┬─────────┐│^│││││││
> > > ││ │││  │││ │││0│3││ │││  │││ ││ │││  │││&│┌─────┬─┐││  │││ ││
> > >  │││&│┌─────┬─┐││ │││││││
> > > ││ │││  │││ ││└─┴─┘│ │││  │││ ││ │││  │││ ││┌─┬─┐│*│││  │││ ││  │││
> > > ││┌─┬─┐│*│││ │││││││
> > > ││ │││  │││ │└─────┴─┘││  │││ ││ │││  │││ │││0│4││ │││  │││ ││  │││
> > > │││0│5││ │││ │││││││
> > > ││ │││  ││└─┴─────────┘│  │││ ││ │││  │││ ││└─┴─┘│ │││  │││ ││  │││
> > > ││└─┴─┘│ │││ │││││││
> > > ││ │││  │└─────────────┴──┘││ ││ │││  │││ │└─────┴─┘││  │││ ││  │││
> > > │└─────┴─┘││ │││││││
> > > ││ ││└──┴──────────────────┘│ ││ │││  ││└─┴─────────┘│  │││ ││
> > >  ││└─┴─────────┘│ │││││││
> > > ││ ││                       │ ││ │││  │└─────────────┴──┘││ ││
> > >  │└─────────────┴─┘││││││
> > > ││ ││                       │ ││ ││└──┴──────────────────┘│
> > > │└──┴─────────────────┘│││││
> > > ││ ││                       │ ││
> > > │└───────────────────────┴─┴──────────────────────┘││││
> > > ││ ││                       │
> > > │└─┴──────────────────────────────────────────────────┘│││
> > > ││
> > >
> > │└───────────────────────┴─┴──────────────────────────────────────────────────────┘││
> > >
> > │└─┴──────────────────────────────────────────────────────────────────────────────────┘│
> > >
> > └──────────────────────────────────────────────────────────────────────────────────────┘
> > >
> > >    (plusR/ (3&*@:*:)`(4&*@:+:)`(5&*@:^))`:6
> > > 3&*@:*: + 4&*@:+: + 5&*@:^
> > >
> > > I hope you can see where we are going...
> > >
> > > Second, ata,
> > >
> > >    ataR=. 4 : 0
> > >   N=. y
> > >   v=. x`:6
> > >
> > >   y=. (as'N&*@:(v f.)')`:6
> > >   5!:1@<'y'
> > > )
> > >
> > >     (<'*:') ataR 3
> > > ┌───────────────────────┐
> > > │┌──┬──────────────────┐│
> > > ││@:│┌─────────────┬──┐││
> > > ││  ││┌─┬─────────┐│*:│││
> > > ││  │││&│┌─────┬─┐││  │││
> > > ││  │││ ││┌─┬─┐│*│││  │││
> > > ││  │││ │││0│3││ │││  │││
> > > ││  │││ ││└─┴─┘│ │││  │││
> > > ││  │││ │└─────┴─┘││  │││
> > > ││  ││└─┴─────────┘│  │││
> > > ││  │└─────────────┴──┘││
> > > │└──┴──────────────────┘│
> > > └───────────────────────┘
> > >    ((<'*:') ataR 3)`:6
> > > 3&*@:*:
> > >
> > > I hope you can take it from here.  I have to run!
> > >
> > > [0] Anonymous Evoke (ae), take 2
> > >
> > >
> > http://www.jsoftware.com/svn/DanBron/trunk/environment/anonymous_evoke2.ijs
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Mon, Apr 20, 2015 at 9:55 AM, Jose Mario Quintana <
> > > [email protected]> wrote:
> > >
> > > > Jon ,by the way you can call me Pepe (Jose's nickname), the problem is
> > > > that I copied the execution of a script as I usually do to show it
> > > > working.  However trying to execute the display can cause all sort of
> > > > problems.  Try the following clean version, with a minor aesthetic
> > change,
> > > > of the script (I hope the EOLs do not get lost in transit).  It should
> > run
> > > > (famous last words?).
> > > >
> > > >
> > > > NB. Collected definitions...
> > > >
> > > > o=. @:
> > > > (x=. o[) (y=. o]) (e=. &.>)
> > > >
> > > > an=. <@:((,'0') ,&< ])
> > > >
> > > > Cloak=. ((5!:1)@:<'Cloak')Cloak=. (0:`)(,^:)
> > > >
> > > > 'at amper evoke'=. Cloak o < e o ;: '@: & `:'
> > > >
> > > > train=. evoke&6 f.
> > > > box=. < o train "0
> > > >
> > > > NB. First...
> > > >
> > > > ( G=. (*:`%: ,. +:`^) )
> > > > ( L=. 1 2 )
> > > >
> > > > process=. train o ([ ; an y)("0) f.
> > > >
> > > > G process 4
> > > > G process L
> > > >
> > > > NB. Second...
> > > >
> > > > plus=. train o ([ , (<'+') , ])
> > > >
> > > > times=. >@:((box <'*')"_)   NB. * boxed
> > > > ata=. (] amper times) at [  NB. amper times at
> > > >
> > > > ( vrb=. > o (box x (< o plus/ .(ata e)) ])f. )
> > > >
> > > > ( G=.  *:`+:`^ )
> > > > ( L=. 3 4 5    )
> > > >
> > > > G vrb L
> > > > G vrb L 1 2 3
> > > >
> > > > The last time I checked debug, a long time ago, was not very tacit
> > > > friendly.  I am a big fan of dissect but it expects (correctly) verbs
> > to
> > > > take nouns and produce nouns and it would  (rightfully) refuse to
> > dissect
> > > > wicked verbs for that reason.
> > > >
> > > > Gerunds and atomic representations are indeed tricky but there is
> > another
> > > > method for dealing with them that you might find less painful.  I will
> > try
> > > > to outline it after work if I have a chance.
> > > >
> > > >
> > > >
> > > >>
> > > ----------------------------------------------------------------------
> > > 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