Re: [Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Brian Schott
I have only worked on part 1 so far. All my verbs are monadic and take the number in question as its argument. evenQ =. = <.&.-: size =. (+evenQ)@>.@%: NB. edge length border =. size-&*:_2+size NB. border length (number) lowest =. 1 _3 4& p. @ -:@<:@size NB. b

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Daniel Lyons
> On Dec 3, 2017, at 10:40 AM, Andrew Dabrowski wrote: > > 2. Is anyone bothered by the lack of a built-in associative list structure? There have been a few times so far that I have thought I needed this, but so far I have found another approach that works better. In one case, I instead jus

Re: [Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Daniel Lyons
> On Dec 3, 2017, at 7:01 PM, Jimmy Gauvin wrote: > > has anybody found something better than a "do. while." to calculate the > spiral neighborhood count? Amusingly, someone made a video about a cool trick for doing this in J, it's about 1/3rd of y'all's Youtube presence: https://www.youtub

Re: [Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Rob Hodgkinson
Eugene McDonnell (worked very closely with Ken Iverson) wrote a wonderful book “At Play With J”, available here; http://code.jsoftware.com/wiki/At_Play_With_J In which the chapter on “volutes” offers a tacit derivation of a non looping alternative to WRAP. An involute counts from outside in to

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread bill lam
J symbol datatype already associated with hash, can an efficient dictionary be implemented with that together with J scripts? Perhaps with some extension to s: On Dec 4, 2017 10:49 AM, "Henry Rich" wrote: > Yeah, I found it, but it wouldn't be applicable here because it > implemented a fixed-si

Re: [Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Jimmy Gauvin
Hi, for part 1, I used the properties of the spiral pattern to find the distance. The spiral matrix can be viewed as a series of concentric rings with the last number of a ring being a perfect square. Calculating the ring number gives me one part of the distance. Finding the distance to the neares

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Henry Rich
Yeah, I found it, but it wouldn't be applicable here because it implemented a fixed-size hashtable and kept only the most recent entries (it was used as a lookaside buffer to speed negascout searches). A simple hashtable wouldn't be hard to implement, methinks. Henry Rich On 12/3/2017 8:18 PM

Re: [Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Joe Bogner
Hi Jimmy - I'm also working with WRAP from the phrases. I messed around with trying to understand https://oeis.org/A054552 but it seemed more complicated than I wanted to undertake. Here's my exploration of my solution for part 1 I'm using this currently to locate the x/y coordinate (probably a b

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread 'Jon Hough' via Programming
This is the hashmap implementation I wrote a while ago, using separate chaining, and using J's OO functionality. Bear in mind I am not a J expert, and when I wrote this I knew even less J. I am pretty sure others have written better implementations, but anyway, this may be useful as a reference

[Jprogramming] Advent of code, Day 3 (spoilers probable)

2017-12-03 Thread Jimmy Gauvin
Hi, has anybody found something better than a "do. while." to calculate the spiral neighborhood count? Is there some underlying mathematical structure that I am not aware of? Thanks, WRAP is from http://www.jsoftware.com/help/phrases/grids.htm spw is the result of the neighbor calculation

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Andrew Dabrowski
Can you locate your code? On 12/03/2017 06:52 PM, Henry Rich wrote: Yes; I've done that before.  It might be worth seeing how well we could make such an addon perform before making changes to the JE. Henry Rich On 12/3/2017 6:47 PM, bill lam wrote: Can this be implemented using j script add

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Henry Rich
Yes; I've done that before.  It might be worth seeing how well we could make such an addon perform before making changes to the JE. Henry Rich On 12/3/2017 6:47 PM, bill lam wrote: Can this be implemented using j script addon? On Dec 4, 2017 5:26 AM, "Henry Rich" wrote: Perhaps we shouldn'

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread bill lam
Can this be implemented using j script addon? On Dec 4, 2017 5:26 AM, "Henry Rich" wrote: > Perhaps we shouldn't try to make a full datatype for associative arrays, > but just a set of functions (foreigns, or (m h.) ) that do what's needed. > > We would need to decide what's needed. > > hashtabl

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Henry Rich
Perhaps we shouldn't try to make a full datatype for associative arrays, but just a set of functions (foreigns, or (m h.) ) that do what's needed. We would need to decide what's needed. hashtable =: keys create values indexes =: hashtable lookup keys (like i.) values =: hashtable fetch indexes 

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Marshall Lochbaum
The associative lists that Andrew is talking about (also called maps or dictionaries) are essentially the same as JSON objects (more precisely, JSON objects are maps whose keys are strings). There's no need for them to be used in a particularly low-level way, although the primitives used to manipul

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Raul Miller
I would use the word "value" rather than "variable" here A=: 1 2 3 A=: 1 3 References to A will pick up whichever value is current at the time of reference. You make a new value and assign it to the same variable. I understand that some languages do things a bit different, where depending on the

Re: [Jprogramming] J strengths?

2017-12-03 Thread Kenneth Lettow
See http://code.jsoftware.com/wiki/Jd/License#License On Sun, Dec 3, 2017 at 1:55 PM, Ron Petersen wrote: > how do i get a copy of JD for my iMac or do i need a other type computer? > > On Sat, Dec 2, 2017 at 2:15 PM, Scott Locklin wrote: > > > On 11/28/2017 3:59 PM, Andrew Dabrowski wrote: > >

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Erling Hellenäs
Hi all! This touches one of the most interesting aspects of J. Variables in J are normally non-mutable in the sense that they can not be modified in-place. You can not set variable A to 1 2 3 and then change it to 1 3 without creating a new variable, but one which might have the same name. This

Re: [Jprogramming] J strengths?

2017-12-03 Thread Ron Petersen
how do i get a copy of JD for my iMac or do i need a other type computer? On Sat, Dec 2, 2017 at 2:15 PM, Scott Locklin wrote: > On 11/28/2017 3:59 PM, Andrew Dabrowski wrote: > > Do you loveJ most because of (pick only one) > > Background: applied math/numerics guy. > > I've worked around big d

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Raul Miller
<<< means "box three times" <2 ┌─┐ │2│ └─┘ <<2 ┌───┐ │┌─┐│ ││2││ │└─┘│ └───┘ <<<2 ┌─┐ │┌───┐│ ││┌─┐││ │││2│││ ││└─┘││ │└───┘│ └─┘ See also the documentation on the index operation (Henry gave you a reference for that). Also, as I understand it, JSON has only a loose relationship

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Henry Rich
1. http://code.jsoftware.com/wiki/Vocabulary/curlylf#Complementary_Indexing_and_Omitted_Axes Henry Rich On 12/3/2017 1:24 PM, Andrew Dabrowski wrote: 1. Yes, I should been more specific: I wanted to know the idiomatic way to delete the nth item of a list, so I think <<< is what I was looking

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Henry Rich
1.  see Raul's response 2. Yes, I am bothered, a little.  When you have something like a symbol table or a position table in a game solver, where you have to do lots of individual insertions and lookups, you might have to write a hashing object.  That has come up often enough for us to have pu

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Andrew Dabrowski
1. Yes, I should been more specific: I wanted to know the idiomatic way to delete the nth item of a list, so I think <<< is what I was looking for. What is <<< called and where is it documented? 2. Not sure what you mean by "Their focus is on micromanaging the sequence of operations."  A-lists

Re: [Jprogramming] delete item; ass. lists

2017-12-03 Thread Raul Miller
Why do you want to delete an item from a list? This is *not* a rhetorical question - we have a variety of ways of removing items from lists and to pick the correct mechanism we need to understand what you are trying to accomplish. To illustrate, here are a few examples: list=: 2 3 4 5 7 8 9 10

[Jprogramming] delete item; ass. lists

2017-12-03 Thread Andrew Dabrowski
1. What's the idiomatic way to delete an item from a list?  This doesn't seem to come up in Learning J.  For that matter, what's a good reference for list slicing ops in J? 2. Is anyone bothered by the lack of a built-in associative list structure?  There are at least two different implementat

Re: [Jprogramming] rank with table and fork

2017-12-03 Thread Raul Miller
Note also that right rank does have significance here: $(+"_ 1 2/~)i. 3 5 5 3 5 3 5 5 $(+"_ 1 3/~)i. 3 5 5 |length error (In other words, remember that the definition of u always matters.) Thanks, -- Raul On Sun, Dec 3, 2017 at 9:06 AM, Joe Bogner wrote: > Thanks for the suggestion to

Re: [Jprogramming] rank with table and fork

2017-12-03 Thread Joe Bogner
I appreciate it. I thought so - but wanted to confirm. NuVoc pages are excellent and go a long way at explaining it. Like many complicated topics, for me at least, its helpful to see it from different angles -- including NuVoc, the dictionary, the various J books and texts, the wikipedia page on r

Re: [Jprogramming] rank with table and fork

2017-12-03 Thread Henry Rich
If you look at the ranks on the NuVoc main page, or at the start of the page for fork or hook, you will see that the ranks for both are all infinite. Verb rank is one of the most important concepts in J, and one of the hardest to explain clearly.  NuVoc has several pages devoted to it, as you

Re: [Jprogramming] rank with table and fork

2017-12-03 Thread Joe Bogner
Thanks for the suggestion to reread and dig into / . I reread the docs and they are clear now. The bits that stick out to me that are relevant to my problem: "1. If the rank of u is not 0, it doesn't produce a table"[1] This seems to be a reference to "u/ y is equivalent to x u"(lu,_) y where lu

Re: [Jprogramming] ubuntu jsoftware install

2017-12-03 Thread Raul Miller
Did you try the non-avx install, mentioned on the second line of that wiki page? Thanks, -- Raul On Sun, Dec 3, 2017 at 5:36 AM, TongKe Xue wrote: > Hi, > > I'm following the instructions at: > > http://code.jsoftware.com/wiki/System/Installation/Linux > > I run into the following issue

[Jprogramming] ubuntu jsoftware install

2017-12-03 Thread TongKe Xue
Hi, I'm following the instructions at: http://code.jsoftware.com/wiki/System/Installation/Linux I run into the following issue: sudo dpkg -i j806_amd64.deb ; echo "===" ; /usr/bin/ijconsole ; echo "==="; uname -a (Reading database ... 88939 files and directories currently installed.) Pr