[Jprogramming] adventofcode 11

2015-12-10 Thread David Lambert
In the session below, the final sentence valid A runs "forever". Why? $ ijconsole JVERSION Engine: j803/2014-10-19-11:11:11 Library: 8.04.13 Platform: Linux 64 Installer: unknown InstallPath: /usr/share/j/8.0.4 LC=: 26}.Alpha_j_ a2v=: _8{.LC&i. NB. these tests apply to numerical

Re: [Jprogramming] regex confusion

2015-12-10 Thread bill lam
I think this is a bug as illustrated by your example. The fix will be in the next base library release. Thanks for reporting with a clear example. ('^B';'C') rxrplc 'BBB my sentence' CBB my sentence ('B';'C') rxrplc 'BBB my sentence' CCC my sentence Пт, 11 дек 2015, Ryan Eckbo написал(а):

Re: [Jprogramming] dyadic J

2015-12-10 Thread Raul Miller
Sorry, no, I meant lambda=: 3 : And I do not claim that the definition is equivalent. I did claim that it is straightforward. Thanks, -- Raul On Thu, Dec 10, 2015 at 5:15 PM, Jose Mario Quintana wrote: > Raul writes: > > " > Also straightforward would be this adverb. > > lambda= 3 : > "

Re: [Jprogramming] advent of code - day 2

2015-12-10 Thread Don Kelly
NuVoc (>0 1 )|: y Don On 12/10/2015 12:13 AM, Linda A Alvord wrote: I'm just getting started on these and here is an elementary school solution. (I couldn't remember a shortcut to get a diagonal from a square matrix. f=: 13 :'(*/0 1{(/:y){y)+2*+/+/(=/~i.$y)*1|."1*/~(/:y){y' Linda -Origi

Re: [Jprogramming] regex confusion

2015-12-10 Thread Ryan Eckbo
Ok I see. Unfortunately rxrplc uses rxmatches, so it was messing me up when I was trying to replace just the first character: ('^B';'C') rxrplc 'BBB my sentence' CCC my sentence On 11 Dec 2015, at 2:52, Alex Shroyer wrote: If you just want the *first* match, use *rxmatch*. Use *rxmatches* in

Re: [Jprogramming] dyadic J

2015-12-10 Thread Jose Mario Quintana
Raul writes: " Also straightforward would be this adverb. lambda= 3 : " lambda = 3 : |value error: lambda | lambda=3 : Did you mean the following? lambda=. 3 : If so, sf=. [: u0 u1 u2 (u0@[ u1 u2@]) lambda |domain error: lambda | sf=.[:u0 u1 u2(u0@[u1 u2@])lambda I am a

Re: [Jprogramming] advent 10

2015-12-10 Thread Henry Rich
We all had the same solution. My version is # ,@((# , {.);.1~ (~: |.!.0))^:40 "."0 '1113122113' Henry Rich On 12/10/2015 10:16 AM, 'Pascal Jasmin' via Programming wrote: I did not know fill on |. worked that way. I see it now. neat. - Original Message - From: Joe Bogner To: pro

Re: [Jprogramming] dyadic J

2015-12-10 Thread 'Pascal Jasmin' via Programming
its pretty much the exact same, T M and T M~. Its 2 definitions instead of 4 (including the reasonable alternatives you mentioned). Somewhat addressing your name conflict concerns. with Y, you can also do this: 2 3 ( 0 Y~) 1 5 2 But then Y is not quite as good a name as M(onad) anymore i

Re: [Jprogramming] dyadic J

2015-12-10 Thread Raul Miller
Also straightforward would be this adverb. lambda= 3 : This expects a formatted sequence of characters as its argument, but it's quite a robust (and well documented) implementation. Thanks, -- Raul On Thu, Dec 10, 2015 at 2:21 PM, Jose Mario Quintana wrote: > I would rather use strand notati

Re: [Jprogramming] dyadic J

2015-12-10 Thread Joe Bogner
I agree that M is simple. It reminds me of the definition of X and Y that has been previously posted. How does it compare to that? Quick search found a definition like this: Y =: (&{::)(@:]) X =: (&{::)(@:[) but it could also be defined as X=: @[ Y=: @] 3 4 (+:X + -:Y) 2 4 7 10 Regarding

Re: [Jprogramming] dyadic J

2015-12-10 Thread Jose Mario Quintana
Regarding the first release of Jx see [0]. Personally, regardless of the availability of Jx, as I said, I prefer in this kind of case, an adverb using strand notation, and one should be able to produce it using an official J (Pascal might give it a try); furthermore, one should also be able to pro

Re: [Jprogramming] dyadic J

2015-12-10 Thread 'Pascal Jasmin' via Programming
took me a few years to realize that dyadic +:is not always a domain error. (its a boolean op). Nearly all of the builtins are ambivalent. I think M is simple and clean enough to use, and I like that you can change the X or Y reference by just removing/adding ~. That's just me, but I thought

Re: [Jprogramming] dyadic J

2015-12-10 Thread 'Pascal Jasmin' via Programming
Here is my template for just a straight fork. useful for allowning n v n constant verb binding. Fork =: 1 : ' 2 : (''u '' , ''('', u lrA , '')'' , '' v"_'')' +/ % Fork # +/ % #"_ FxHy =: 1 : ' 2 : (''u@[ '' , ''('', u lrA , '')'' , '' v@]'')' +: % FxHy -: +:@[ % -:@] These are adv

Re: [Jprogramming] dyadic J

2015-12-10 Thread Joe Bogner
shorter: sfork=:(1 : '(4 0 1 5 6 2 3) C. (;: ''@[ @]'') , (1{:: 0{:: u`[)') 1 : 'u`:6' 3 4 (+: + -:) sfork 2 4 Here's a version that will check to see if the tines are in a list of monads (proof of concept) buildTrain is a mess to look at NB. creates and documents a function NB. could be impro

Re: [Jprogramming] dyadic J

2015-12-10 Thread Raul Miller
On Thu, Dec 10, 2015 at 2:21 PM, Jose Mario Quintana wrote: > I would rather use strand notation (a multiple adverb). Using Jx and the > adverb lambda mentioned in [0] is straightforward: Personally, I don't even remember where to download Jx - nor do I know where to find docs on how it differs

Re: [Jprogramming] dyadic J

2015-12-10 Thread Jose Mario Quintana
I would rather use strand notation (a multiple adverb). Using Jx and the adverb lambda mentioned in [0] is straightforward: sf=. [: u0 u1 u2 (u0@[ u1 u2@]) lambda +: + -:sf +:@[ + -:@] 3 4 +: + -:sf 2 4 7 10 type'sf' ┌──┐ │adverb│ └──┘ [0] [Jprogramming] Can whatever be wr

Re: [Jprogramming] dyadic J

2015-12-10 Thread Joe Bogner
Oh, that is clever but not too mysterious. I also went down the path of trying to get the linear representation of u but got stuck because 5!:5 expects a name. I didn't think to assign a local name. This was also cool and the piece I was missing to gerundify u (+: + -:) (1 : '0{:: u`[') ┌─┬──

Re: [Jprogramming] dyadic J

2015-12-10 Thread Raul Miller
Here's a draft implementation of what I think you mean by a "smart fork": NB. draft sfork=:1 :0 impl=. 0 {:: u`- if. (<,'3')-:{.impl do. d=. 5!:1@< e=. 5!:0 '`a b c'=. 1 {:: impl (d'a')e@[ (d'b')e (d'c')e@] end. ) Example use: (+-*)sfork +@[ - *@] Hopefully that's not to

Re: [Jprogramming] dyadic J

2015-12-10 Thread Joe Bogner
Interesting. I'm not sure if M is worth it over @] due to potential naming conflicts and ambiguity in the code .@] is very clear It got me thinking that it might be interesting (albeit probably not overly useful) to have a 'smart fork' adverb that could figure out that its arguments are monadic an

Re: [Jprogramming] Jconsole : printing the complete content of a J object (no ...) ?

2015-12-10 Thread Akaki Ma
On 03/12/2015 9:10 AM, bill lam wrote: Right, 9!:36/37 is needed but not sufficient for Jconsole, since it also depends on the scrolling capability of the terminal emulator. Thanks for this additional info, which i was not aware of. I am using jconsole under windows 7 command prompt. Scrolling

Re: [Jprogramming] dyadic J

2015-12-10 Thread 'Pascal Jasmin' via Programming
Here is another approach to simplifying J and meeting dyadic J goals without verb definitions: M =: @] 3 4 (+:M~ + -:M) 2 4 7 10 (+: M~ + -: M) 2 4 5 10 ~ (swap) basically works like @[ on a monad that is defined to ignore x rather than return error. M or M~ is easier to type than @

Re: [Jprogramming] Jconsole : printing the complete content of a J object (no ...) ?

2015-12-10 Thread Akaki Ma
Hi!, Sorry for the late response. I was subscribed with digest mode only. Took me some time to find how to respond to individual messages. So thanks for your help. Which is, of course, exactly what i needed. -- For information

Re: [Jprogramming] advent of code - day 2

2015-12-10 Thread Linda A Alvord
Thanks Raul, I got to that section of phrases but didn't scroll down far enough. I like the fork in the tree better. m7=:(<0 1)&|: f=: 13 :'(<0 1) |:y' 5!:4 <'m7' -- <0 1 -- & -+- |: 5!:4 <'f' -- <0 1 --+- |: L- ] m7 (<0 1)&|: f (<0 1) |: ]

Re: [Jprogramming] advent 8

2015-12-10 Thread Joe Bogner
> On Thu, Dec 10, 2015 at 3:52 AM, Ryan Eckbo wrote: Also someone could probably write a clever verb to generate the table. >> I don't know if it's clever, but here's one that matches Raul's input matrix (|@((_0.1)&+)@{. , ] ) |: (10 10 $ _0.2,(10 # 0)) + (i.10) +/ (10 # 0.2) 0.1 1.1 2.1 3.1 4

Re: [Jprogramming] regex confusion

2015-12-10 Thread Alex Shroyer
If you just want the *first* match, use *rxmatch*. Use *rxmatches* in when you want to keep doing *rxmatch* on the rest of the string after finding a match, until the end of the string. On Thu, Dec 10, 2015 at 6:33 AM, bill lam wrote: > I think this is the way that rxmatches works, it iterates

Re: [Jprogramming] advent 8

2015-12-10 Thread Raul Miller
I would be tempted to express your S like this: SM=: 0 10#: 10* 1+ ".;._2 noun define 0.1 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1NB. initial 0.0 1.2 2.2 3.2 4.2 5.2 6.2 7.2 8.2 9.2NB. 0 0.2 1.0 2.2 3.2 4.2 5.2 6.2 7.2 8.2 9.2NB. 1 0.2 1.2 2.

Re: [Jprogramming] advent 10

2015-12-10 Thread 'Pascal Jasmin' via Programming
I did not know fill on |. worked that way. I see it now. neat. - Original Message - From: Joe Bogner To: programm...@jsoftware.com Sent: Thursday, December 10, 2015 9:40 AM Subject: Re: [Jprogramming] advent 10 Thanks, the fill is needed otherwise it would return the wrong result if

Re: [Jprogramming] advent of code - day 2

2015-12-10 Thread Raul Miller
On Thu, Dec 10, 2015 at 3:13 AM, Linda A Alvord wrote: > (I couldn't remember a shortcut to get a diagonal from a square matrix. m7, m8, m9 and m10 from http://www.jsoftware.com/help/phrases/special_matrices.htm get the main diagonal (leading from the upper left corner to the lower right of the t

Re: [Jprogramming] advent 10

2015-12-10 Thread Joe Bogner
Thanks, the fill is needed otherwise it would return the wrong result if the last number is the same as the first. I don't think my version is susceptible to that but would be interested to find an example if it is correct: (,@((#,{.);.1~ _1&(|.!._) ~: ])) (1 1 1 3 2 2 2 1 1 1) 3 1 1 3 3 2 3 1

Re: [Jprogramming] advent 10

2015-12-10 Thread 'Pascal Jasmin' via Programming
You may have gotten lucky with _1&|. (fill not needed afaiu) an improvement to mine, after seeing yours. # ,@( ((# , {. );. 1)~ 1 , 2 ~:/\ ])^:(40) 1 1 1 3 2 2 2 1 1 3 - Original Message - From: Joe Bogner To: programm...@jsoftware.com Sent: Thursday, December 10, 2015 8:47 AM Subj

Re: [Jprogramming] advent 10

2015-12-10 Thread Joe Bogner
Clever use of the state machine. I enjoy seeing those... Here's mine: NB. part 1 # (,@((#,{.);.1~ _1&(|.!._) ~: ]))^:40 input=:(1 1 1 3 2 2 2 1 1 3) 252594 NB. part 2 # (,@((#,{.);.1~ _1&(|.!._) ~: ]))^:50 input=:(1 1 1 3 2 2 2 1 1 3) 3579328 To explain, we are going to use cut to split the

Re: [Jprogramming] regex confusion

2015-12-10 Thread bill lam
I think this is the way that rxmatches works, it iterates by beheading the right argument so that ^B match 3 times. Not sure this is a bug or a feature. Чт, 10 дек 2015, Ryan Eckbo написал(а): > I believe there should only be one match. Why are there 3? > > load'regex' > '^B' rxmatches 'BBB my s

[Jprogramming] regex confusion

2015-12-10 Thread Ryan Eckbo
I believe there should only be one match. Why are there 3? load'regex' '^B' rxmatches 'BBB my sentence' 0 1 1 1 2 1 -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] 'Tis the Season...

2015-12-10 Thread Linda A Alvord
Here's a way of doing Advent 1 in Grade. Find all the first kind. Count them. Do the same with the second. Then subtract. Discuss a possible meaning when "It can't be done" s=: 13 :'(?y#2){''()''' [S=:s 10 )()))( f=: 13 :'(+/''(''=y)-+/'')''=y' f S _6 Linda -Original Message

[Jprogramming] advent 10

2015-12-10 Thread Ryan Eckbo
Oops, typo in the title - this is for day 10, not 8. On 10 Dec 2015, at 19:52, Ryan Eckbo wrote: A previous advent answer got me thinking about state machines, so I wrote one for this problem. The extra initial state ruins the natural mapping between states and numbers, but I think it's unav

[Jprogramming] advent 8

2015-12-10 Thread Ryan Eckbo
A previous advent answer got me thinking about state machines, so I wrote one for this problem. The extra initial state ruins the natural mapping between states and numbers, but I think it's unavoidable? Also someone could probably write a clever verb to generate the table. NB. state machin

Re: [Jprogramming] advent of code - day 2

2015-12-10 Thread Linda A Alvord
I'm just getting started on these and here is an elementary school solution. (I couldn't remember a shortcut to get a diagonal from a square matrix. f=: 13 :'(*/0 1{(/:y){y)+2*+/+/(=/~i.$y)*1|."1*/~(/:y){y' Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto