"I'm really just playing around with J. Not using it for serious stuff."

Then I would say that I find your toys interesting.  At any rate, the verb
(as) that I mentioned in this thread often provides me with insights.  If
were forced to write this conjunction in an orthodox manner I would
probably do it as follows:


   plus=. [ , (<'+') , ]

   an=. <@:((,'0') ,&< ])
   ata=. an@:] , (;:'&*@:') , [

   vrb=. plus/ .(ata"0)

   cnj=. '(x vrb y) `:6' (2 :)

   (*:`+:`^) cnj 3 4 5
3&*@:*: + 4&*@:+: + 5&*@:^


Which is almost tacit except for the last step in its definition which
cannot be done tacitly (and runs several times faster and leaner that the
previous orthodox version I posted).  I would even consider a cryptic
one-liner:

   cnj=. '(x ([ , (<''+'') , ])/ .((<@:((,''0'') ,&< ])@:] , (;:''&*@:'') ,
[)"0) y)`:6' (2 :)

   (*:`+:`^) cnj 3 4 5
3&*@:*: + 4&*@:+: + 5&*@:^

 Jon, I hope it helps and good luck with your projects.





On Fri, Apr 24, 2015 at 7:33 AM, Jon Hough <[email protected]> wrote:

> >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
> >
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to