Re: [Jprogramming] aoc day 20

2017-12-20 Thread Jimmy Gauvin
Mea culpa : While "Smallest acceleration wins long term" is a good first approximation, it does not cover the case when there are many equal smallest accelerations. On Wed, Dec 20, 2017 at 12:09 PM, Jimmy Gauvin wrote: > ​​ > ​​ > Another spoiler for part 1 in the tradition of APL one-liners: >

Re: [Jprogramming] sparse negative take

2017-12-20 Thread 'Mike Day' via Programming
Yes - the point is that     _5 {. vector NB. whether sparse or not returns a NEW vector whose indices range from 0 to 4, whether sparse or not Mike On 20/12/2017 23:31, robert therriault wrote: Henry, With further thought, I suppose that what is happening is that the array remains a sparse

Re: [Jprogramming] sparse negative take

2017-12-20 Thread robert therriault
Henry, With further thought, I suppose that what is happening is that the array remains a sparse type and that the indices now reflect the new shape after the selection. Which does make sense when I think about it, but I guess I had it in my mind that the indices would remain attached to the va

[Jprogramming] AoC 13

2017-12-20 Thread Brian Schott
I am getting the wrong answer for part 1 of day 13. Can someone give me a hint what I am misunderstanding? My main verb is day13, but it depends on the following simple verbs. ud =: i.,}.@i.@- spos =: [{.@:|."0 1 ud@] (i. 6) spos"0/ ]3 2 0 0 4 0 4 0 0 0 0 0 0 0 1 1 0 0 1 0 1 2 0 0 0 2 0

Re: [Jprogramming] sparse negative take

2017-12-20 Thread robert therriault
Henry, I think Brian may be referring to the indices shown in the sparse representation. t=: $. 0 0 1 0 2.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 999 _ 0 0 0 t NB. Index values as expected 2 │ 1 4 │ 2.5 19 │ 2 21 │ 999 22 │ _ _5{. t NB. I would have expected 21 and 22 to match the

Re: [Jprogramming] sparse negative take

2017-12-20 Thread Henry Rich
No, _5 {. z has shape 5. Henry Rich On 12/20/2017 6:04 PM, Brian Schott wrote: Negative take seems screwy. $ y=: 0 0 1 0 2.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 999 _ 0 0 0 26 _5{. z NB. Should the 0 and 1 be large numbers? 0 │ 999 1 │ _ 5{. z 2 │ 1 4 │ 2.5 -- -

[Jprogramming] sparse negative take

2017-12-20 Thread Brian Schott
Negative take seems screwy. $ y=: 0 0 1 0 2.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 999 _ 0 0 0 26 _5{. z NB. Should the 0 and 1 be large numbers? 0 │ 999 1 │ _ 5{. z 2 │ 1 4 │ 2.5 -- -- For information about J

Re: [Jprogramming] tail recursion optimization?

2017-12-20 Thread Dabrowski, Andrew John
Thanks, I'll check it out, although I don't use Windows either. On 12/20/2017 03:56 PM, Raul Miller wrote: The stack size can be changed by editing the executable. I have not tested whether the procedure documented at http://www.jsoftware.com/release/recurlim.htm still works (I am not using a win

Re: [Jprogramming] tail recursion optimization?

2017-12-20 Thread Henry Rich
There are several stacks: stacks of debug frames, stacks of executing named entities, and the C execution stack.  All you can change, I think, is the C stack.  Enlarge this if you get a crash during recursion.  Overrunning the other stacks gives stack error. Henry RIch On 12/20/2017 3:56 PM,

Re: [Jprogramming] tail recursion optimization?

2017-12-20 Thread Raul Miller
The stack size can be changed by editing the executable. I have not tested whether the procedure documented at http://www.jsoftware.com/release/recurlim.htm still works (I am not using a windows machine at the moment). Thanks, -- Raul On Wed, Dec 20, 2017 at 3:52 PM, Raul Miller wrote: > Recur

Re: [Jprogramming] tail recursion optimization?

2017-12-20 Thread Raul Miller
Recursion on substructures of an argument is not tail recursion. Use full recursion for that. Tail recursion can only occur when the result of the function you are calling will be the result of your current evaluation instance. Thanks, -- Raul On Wed, Dec 20, 2017 at 3:34 PM, Dabrowski, Andre

Re: [Jprogramming] tail recursion optimization?

2017-12-20 Thread Dabrowski, Andrew John
This isn't a complete workaround for tail recursion though. The while function F^:test^:_ arg doesn't lend itself e.g. to recursion on substructures of arg. To exercise my J muscles I've been playing around with 3n+1 problem, and I very quickly ran into stack errors. Is there a way to expand

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
I move the thread to the Chat forum. Subscription is here: http://www.jsoftware.com/mailman/listinfo/chat /Erling On 2017-12-20 19:45, Raul Miller wrote: Then this thread belongs on the chat forum. As documented on http://forums.jsoftware.com: chat - all other discussions on computer languages

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
Then this thread belongs on the chat forum. As documented on http://forums.jsoftware.com: chat - all other discussions on computer languages and J Thanks, -- Raul On Wed, Dec 20, 2017 at 1:32 PM, Erling Hellenäs wrote: > Hi all! > > Thanks, I will look into the details tomorrow, but yes ,

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
Hi all! Thanks, I  will look into the details tomorrow, but yes , and I see a number of problems with this as mentioned in this post: http://www.jsoftware.com/pipermail/programming/2017-December/050179.html In this thread I am trying to discuss strategies to solve these problems. Pesch[1986] mi

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
Ick. -- Raul On Wed, Dec 20, 2017 at 12:52 PM, 'Bo Jacoby' via Programming wrote: > I am impressed by the J programming language and by the array concept. > However, boxed arrays and sparse arrays and empty arrays illustrate > shortcomings in the array concept of J. > I suggest using ordinal

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread 'Bo Jacoby' via Programming
I am impressed by the J programming language and by the array concept. However, boxed arrays and sparse arrays and empty arrays illustrate shortcomings in the array concept of J.  I suggest using ordinal fractions for structuring, storing and handling data. Then there is no need for boxing, nor

Re: [Jprogramming] aoc day 20

2017-12-20 Thread Jimmy Gauvin
​​ ​​ Another spoiler for part 1 in the tradition of APL one-liners: {. /:+/"1|_3{."1 ". ;._2 (1!:1 <'\\AOC2017\Day20input.txt') -. 'pva=<>' NB. Smallest acceleration wins long term On Wed, Dec 20, 2017 at 11:34 AM, Jimmy Gauvin wrote: > Where do the candy cane and the barber come from? > Ha

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread Dabrowski, Andrew John
Ah, I forgot that = has its own rank, that was silly. Thank you. On 12/20/2017 12:35 AM, bill lam wrote: = is rank 0 -: is rank infinity Try 0= 1$0 and 0-: 1$0 and note the shape of results On Dec 20, 2017 1:16 PM, "Dabrowski, Andrew John" wrote: Here's my lat

Re: [Jprogramming] aoc day 20

2017-12-20 Thread Jimmy Gauvin
Where do the candy cane and the barber come from? Have the elves been playing with your code? C A N D Y S C A N E R S P O I L E R S P O I L E R S P O I L E R S P O I L E R S P O I L E R S P O I L E R B A R B E R P On Wed, Dec 20, 2017 at 9:17 A

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Jimmy Gauvin
There is a bit of information in this thread: https://stackoverflow.com/questions/46967744/rank-operator-vs-axis-notation On Wed, Dec 20, 2017 at 4:37 AM, Erling Hellenäs wrote: > What I found in this paper is that Rank was a concept already in some APL > dialects. It was not new to J. I did no

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Jose Mario Quintana
> For this to happen J functions have to be defined for handling arrays of nothing? I have not followed this thread, or any other recent thread, closely but this might shed some light: " Zero Frame. If the frame contains 0 (as in 3 *"1 i. 0 4), there are no argument cells to apply v to, and the s

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
That might be, but that phrasing still doesn't make sense: */ '' 1 There's no list result here - that's a rank 0 result. Thanks, -- Raul On Wed, Dec 20, 2017 at 9:41 AM, 'Mike Day' via Programming wrote: > I think Erling meant "add" in the sense of appending 1 to the empty list, > rather

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread 'Mike Day' via Programming
I think Erling meant "add" in the sense of appending 1 to the empty list, rather than "add" as an arithmetical operation. That's my n-penny-worth! Mike On 20/12/2017 12:25, Raul Miller wrote: You are multiplying, not adding. -- Raul On Wed, Dec 20, 2017 at 3:39 AM, Erling Hellenäs wrote:

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
(1) this is not a problem with the Rank operator (2) wrong forum - almost none of the messages here have any programming in them and almost none of this is about writing j programs. Thanks, -- Raul On Wed, Dec 20, 2017 at 9:00 AM, Erling Hellenäs wrote: > We have a problem in the Rank operator

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
For u/ '' the interpreter uses the value of 'x' 1 :(u b. 1) 'x' I'm not sure why J returns a linear representation rather a verb, but I'd rather complain about that than its use of identities when the user asks it to insert a verb between nothing. Thanks, -- Raul On Wed, Dec 20, 2017 at 8:57

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
Hi all! These two F# programs describe what initiates the special handling. It might be different in J, but the functionality should be the same, at least from what my tests show. Except from the error case. JWithATwist hides no error cases.    let rec RankMonadic uVerb functionRank  xNoun :

[Jprogramming] aoc day 20

2017-12-20 Thread David Lambert
First time I've used Nub Sieve,    24 20$23{.1j1#'SPOILER' S P O I L E R    S P O I L E R   S P O I L E R S P O I L E  R  S P O I L E R  S P O  I L E R  S C A N D Y  S C A N E R     S P O I L E R    S P O I L E R   S P O I L E R  S P O I  L

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
We have a problem in the Rank operator, which I described. I am trying to create a discussion about solutions to this problem. /Erling Den 2017-12-20 kl. 13:31, skrev Raul Miller: Actually, J does support arrays of nothing. That's what i.0 is, after all. And, if you want a scalar containing a

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
The interpreter adds different startvalues depending on the left verb argument to Insert. /Erling Den 2017-12-20 kl. 13:25, skrev Raul Miller: You are multiplying, not adding. -- For information about J forums see http://ww

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
Actually, J does support arrays of nothing. That's what i.0 is, after all. And, if you want a scalar containing an array of nothing, then a: matches that specification. And we have an algebra here - though if (as in your previous message) you do multiplication and call it addition, this becomes v

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Raul Miller
You are multiplying, not adding. -- Raul On Wed, Dec 20, 2017 at 3:39 AM, Erling Hellenäs wrote: > */i.0 > > 1 > > Here the interpreter automatically adds a 1 to get this peculiar result. > > /Erling > > Den 2017-12-19 kl. 20:01, skrev Raul Miller: >> >> An empty tank zero array would be incons

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread Erling Hellenäs
Hi all ! It seems to look into the boxes and follow the rules described in the essay.    lt=: 1 0 -: \:@,&<    /:~ (,1);2 ┌─┬─┐ │2│1│ └─┴─┘    lt//:~ (,1);2 1    $&.>/:~ (,1);2 ┌┬─┐ ││1│ └┴─┘ As we can see <2 is smaller than <,1. Cheers, Erling Hellenäs Den 2017-12-20 kl. 11:32, skrev Erlin

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread Erling Hellenäs
http://code.jsoftware.com/wiki/Essays/The_TAO_of_J /Erling Den 2017-12-20 kl. 11:27, skrev bill lam: Grade up is defined in j dictionary. IIRC there is also an essay in jwiki on TAO ( total array order) by Roger Hui. -- For inf

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread bill lam
Grade up is defined in j dictionary. IIRC there is also an essay in jwiki on TAO ( total array order) by Roger Hui. -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread Erling Hellenäs
Hi all ! More interesting features with boxed data:     1;,1 ┌─┬─┐ │1│1│ └─┴─┘    (,1);1 ┌─┬─┐ │1│1│ └─┴─┘     You can compare boxes with Equal but not with Less Than or Larger Than. Anyway, Grade Up considers one larger than the other. Are these comparisons done on the binary representation

Re: [Jprogramming] scalars vs. lists in boxes

2017-12-20 Thread Henry Rich
To put this another way, (x = y) compares atoms and will produce an array if applied to an array (and will give length error if applied to arrays that don't agree).  (x -: y) answers the question 'are these things the same?' and returns 0 or 1. In if.-statements, you usually want -: if. x =

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
What I found in this paper is that Rank was a concept already in some APL dialects. It was not new to J. I did not find any direct comparison between the axis notation and the rank notation which could justify the selection of the latter for J. /Erling Den 2017-12-19 kl. 16:31, skrev Erling H

Re: [Jprogramming] Another Quora problem

2017-12-20 Thread Erling Hellenäs
My take:   (((0=60|])*.0~:24|])#])1+i.1000 60 180 300 420 540 660 780 900 /Erling Den 2017-12-19 kl. 19:52, skrev 'Skip Cave' via Programming: How many numbers from 1 to 1000 are divisible by 60 but not by 24? Here's my somewhat inelegant explicit solution: #e=.c#~d=.-.0=24|/c=.a#~b=.0=

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
We have two questions here. One is if it is natural that an array without dimensions have one item. The other one is if there could be an item, but an empty one. /Erling Den 2017-12-19 kl. 20:01, skrev Raul Miller: An empty tank zero array would be inconsistent. The number of elements in an

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
Hi all ! Could we avoid doing these peculiar things in the rank operator if we enabled the handling of arrays of nothing? The verb injected in Rank would then have to give a valid result for an array of nothing? For this to happen J functions have to be defined for handling arrays of nothi

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
This is a mathematical concept: https://en.wikipedia.org/wiki/Empty_product /Erling Den 2017-12-20 kl. 09:39, skrev Erling Hellenäs: */i.0 1 Here the interpreter automatically adds a 1 to get this peculiar result. /Erling Den 2017-12-19 kl. 20:01, skrev Raul Miller: An empty tank zero arr

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
*/i.0 1 Here the interpreter automatically adds a 1 to get this peculiar result. /Erling Den 2017-12-19 kl. 20:01, skrev Raul Miller: An empty tank zero array would be inconsistent. The number of elements in an array is the product of its dimensions, and the multiplicative identity is 1, not

Re: [Jprogramming] The n-cell model of an array

2017-12-20 Thread Erling Hellenäs
Hard to follow how this leads to a rank 0 array containing one item. /Erling Den 2017-12-19 kl. 20:01, skrev Raul Miller: An empty tank zero array would be inconsistent. The number of elements in an array is the product of its dimensions, and the multiplicative identity is 1, not 0. Thanks,