Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Michal D.
You may very well be correct that the box representation is the right way to go. It does provide a nice separation between array land and data with arbitrary structure. I'll have to take some time to digest the various approaches presented here. Cheers, Mike On Mon, Sep 8, 2014 at 11:09 AM, 'P

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Michal D.
Thanks for the links, they make for interesting reading. I agree that the elegance of the solution is the hard part. Nevertheless there have been previous attempts at ragged arrays that we can potentially learn from: nested arrays in APL and K to some degree. I was hoping to find out more about

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Michal D.
One can imagine that it's possible for ] x =. (<@i."0) 1+i.3 +-+---+-+ |0|0 1|0 1 2| +-+---+-+ to be laid out in memory as [0 0 1 0 1 2] with an additional vector representing the starting point of each rank-1 array [0 1 3 6]. I would be willing to wager a large sum that this is much

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
In my example, I show how the predecessor-index data structure can be used to express both depth-first and breadth-first trees. I also give examples of doing some useful operations on trees using this structure. I don't yet see any advantage to using ordinal fractions since I've seen no examples

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Linda Alvord
That's it! Thanks. Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller Sent: Monday, September 08, 2014 9:03 PM To: Programming forum Subject: Re: [Jprogramming] Ragged Array Shapes are Trees

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
Given what I understand of your style, I think you are looking for h=: 13 :'([: < [:$>)"0 y' Thanks, -- Raul On Mon, Sep 8, 2014 at 7:51 PM, Linda Alvord wrote: > > How can you define h to use the definition of &, so that the result is the > same as that for f and g : > > ]A=:((i.2

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
Point taken. But neither you nor I (for example) have bothered to be interested enough in Red Black trees to implement anything better. And for a problem that size, it's really not right to put an hour into criticizing it when an hour could have been used to show what you mean using an actual impl

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Linda Alvord
How can you define h to use the definition of &, so that the result is the same as that for f and g : ]A=:((i.2 3);(,0)) ; (i. 2 3) ┌─┬─┐ │┌─┬─┐│0 1 2│ ││0 1 2│0││3 4 5│ ││3 4 5│ ││ │ │└─┴─┘│ │ └─┴─┘ f=: 13 :'$ each y' f A ┌─┬───┐ │2│2 3│

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Dan Bron
Yes, but to Devon's point, having a direct transliteration of an algorithm originally expressed in a (very) different language doesn't tell us anything about J's power (or not) to express that algorithm. Any programming language worth discussing is Turing complete. Which means they're all *capa

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
It is, nevertheless, an implementation. And anyone that feels like doing so can supply other alternates (or replace it, if they feel theirs is good enough). Thanks, -- Raul On Mon, Sep 8, 2014 at 5:28 PM, Devon McCormick wrote: > This looks like a transliteration from another language - not

Re: [Jprogramming] joxygen not working for me

2014-09-08 Thread chris burke
When I tested this on Windows, installing Pandoc put it on the path, so that no change was needed to the shell call in makescript. Can you experiment to find out why this is not working on your machine? You should be able to call pandoc from the command prompt with the same expression. On Mon, Se

Re: [Jprogramming] joxygen not working for me

2014-09-08 Thread tom arneson
Chris, After posting I looked at joxygen.ijs and saw that it used Pandoc. I downloaded & installed it. The installer put it in: C:\Users\Tom Arneson\AppData\Local\Pandoc I modified the shell line in makescript to: shell '"C:\Users\Tom Arneson\AppData\Local\Pandoc\pandoc" ',m,' -c "joxygen.css"

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread 'Bo Jacoby' via Programming
DevonMcCormick's example C: |__n0 | |_n00 | |_n01 | |__n1 |__n10 | |__n100 |__n11 | |__n110 | |__n111 | |__n112 |__n12 is expressed by ordinal fraction like this: 0 |__1 | |__11 | |__12 | |__2 |__21 | |__211 |__22 | |__221 | |__222 | |__223 |__23 This tree

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
This looks like a transliteration from another language - not J-like at all. Once clue is that it's several times as long as many of the other implementations. On Mon, Sep 8, 2014 at 4:05 PM, Joe Bogner wrote: > I found an implementation of red-black trees on rosettacode: > http://rosettacode.

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread 'Pascal Jasmin' via Programming
I think that is awesome, Thomas. For those who didn't load the code, its much easier to use than it looks as everything is a verb, and the whole thing is like a mini stack language, and each operation produces intuitive and visible results. - Original Message - From: Thomas Costigli

Re: [Jprogramming] joxygen not working for me

2014-09-08 Thread chris burke
It works for me. Perhaps you don't have Pandoc installed? The docs need to make it clear that this is needed to build the output. On Mon, Sep 8, 2014 at 12:23 PM, tom arneson wrote: > I'm trying to use Joxygen and the example in the wiki doesn't work for me: > > > > The script ~addons/docs/joxyg

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Joe Bogner
I found an implementation of red-black trees on rosettacode: http://rosettacode.org/wiki/Pattern_matching#J ... It might be relevant or may not be. On Mon, Sep 8, 2014 at 3:45 PM, Devon McCormick wrote: > A little research clarified what we see here: apparently it's part of the > definition of

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Thomas Costigliola
Array representations and "pointer" representations of trees both have their uses. In the end it depends on what problem you are trying to solve. As Devon demonstrated, for his purpose, array representation was not a hindrance at all. But, as Dan mentions, trees are also used to implement abstract

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
A little research clarified what we see here: apparently it's part of the definition of a binary tree that the left node be smaller than its parent but the right one is greater. Right away, I see a problem for the predecessor-index representation of a tree that I'm advocating as it does not distin

[Jprogramming] joxygen not working for me

2014-09-08 Thread tom arneson
I'm trying to use Joxygen and the example in the wiki doesn't work for me: The script ~addons/docs/joxygen/test.ijs builds docs from source in the ~addons/docs/joxygen/testscripts directory, with output to ~temp/joxygen. The output should match the example output in ~addons/docs/joxygen/testd

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread 'Pascal Jasmin' via Programming
in terms of copying one node to another, ((1 ; 0)&{:: <@[ each amendT 0 ]) 0 ;<(< i.5);i.4 ┌───┬─┐ │┌─┐│┌───┬───┐│ ││0 1 2 3 4│││┌─┐│0 1 2 3││ │└─┘│││0 1 2 3 4││ ││ │ ││└─┘│ ││ │ │└

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
At a minimum, I hope we can be a tad more elegant than this: http://www-cs.ccny.cuny.edu/~peter/dstest/h_bl_tree.c . On Mon, Sep 8, 2014 at 3:03 PM, Devon McCormick wrote: > Do you have a reference to a good example of this? Looking at the > "before" and "after" pictures on the right here - >

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
Do you have a reference to a good example of this? Looking at the "before" and "after" pictures on the right here - http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree - the rebalancing seems arbitrary as it preserves some relations but changes others. On Mon, Sep 8, 2014 at 2:30 PM,

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
This is a very natural way of expressing trees in J. And, this shows some of the pain of using trees - no one tends to like any particular tree implementation. The grass is always greener on the other side of the fence. (And the "point" of trees often seems to be mediocrely efficient - defining a

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Dan Bron
Raul wrote: > Note that J already supports trees. Devon wrote: > I have J code that uses trees which I run daily and > have been doing so for years. Pascal wrote: > I think trees are done at least ok, if not "right" already. Challenge: express, in J, the logic of rebalancing a heap (say, a Fi

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread 'Pascal Jasmin' via Programming
I think trees are done at least ok, if not "right" already. I think Michal might be thinking of reinventing the box. I view trees as lists of lists, where the right hand side of "of" might as well be anything including subtrees. So tree's are inherently polymorphic, and even if limited to only

Re: [Jprogramming] Trampolining (was Adler-32)

2014-09-08 Thread Jose Mario Quintana
This completes the performance TCO comparison (for dyadic ! aka binomial coefficients); the following code includes undefined utilities but the fixed code shown for the verbs has a proper linear representation JVERSION Installer: j602a_win.exe Engine: j701/2012-12-06/12:20/x Library: 6.02.023

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Dan Bron
I expand on this in a little more detail in the Wiki page I linked to, but (in my view), there are two aspects to address w.r.t. trees in J; efficiency is one of the two questions, but the less interesting one ("efficiency is a SMOP" [1]). The other, more interesting question, is "convenience". Is

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Devon McCormick
"The best is the enemy of the good" I have J code that uses trees which I run daily and have been doing so for years. The simple and efficient way I handle trees - using an idea from APL days - is outlined here: http://www.jsoftware.com/jwiki/DevonMcCormick/Trees . The code I run daily - which p

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
Note that J already supports trees. After all, that's what directories are, and J supports directories (albeit using foreigns). As for the efficiency of trees, well... you can see for yourself, from first hand experience. Operating systems, after all, have many many years of effort which have gon

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Dan Bron
I do think trees, if we did it right (that is, treated as first class citizens in their own right, as opposed to a subtype or a different perspective on "arrays"), would be a powerful extension to the language. That would take some serious thought, though: for one thing, trees, by their nature, en

Re: [Jprogramming] Replace one item of a list

2014-09-08 Thread Jose Mario Quintana
Linda wrote: " The verb is amend and the main issue is that you must separate 100 and 2 or they become the list 100 2 " Actually, amend (}) is an adverb and the verb is (2}). Roger wrote: " a=: 100 (2}) a " The form that Roger gave makes that apparent: test=. 2} type'test' ┌┐ │verb

Re: [Jprogramming] Replace one item of a list

2014-09-08 Thread Don Guinn
That is not really an issue in the general case where the index and/or the replacement value vary. As one would expect in the more general case. a=.100 b=.2 a b} A=.i.5 0 1 100 3 4 On Mon, Sep 8, 2014 at 9:13 AM, Linda Alvord wrote: > The verb is amend and the main issue is that you mu

Re: [Jprogramming] Replace one item of a list

2014-09-08 Thread Linda Alvord
The verb is amend and the main issue is that you must separate 100 and 2 or they become the list 100 2 100 (2)} A=.i.5 0 1 100 3 4 (100) 2} A=.i.5 0 1 100 3 4 Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forum

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Raul Miller
What does this mean "shapes extended to support ragged arrays without boxing"? K has ragged arrays without boxing, but K's concept of shape only applies to the non-ragged prefix dimensions. Meanwhile, it seems to me that the guarantee you suggest would be computationally expensive. (Not saying t

Re: [Jprogramming] Ragged Array Shapes are Trees

2014-09-08 Thread Michal D.
Thanks Pascal, that's a nice formulation for the 2-level deep case. It breaks down of course for deeper nesting but could serve as a base. ([:|. $ ;~ $ each) ((i.2 3);(,0)) ; (i. 2 3) +-+---+ |2|+-+---+| | ||2|2 3|| | |+-+---+| +-+---+ There's no specific problem I'm trying to solve

Re: [Jprogramming] Replace one item of a list

2014-09-08 Thread Roger Hui
a=: i.5 a 0 1 2 3 4 a=: 100 (2}) a a 0 1 100 3 4 On Mon, Sep 8, 2014 at 7:18 AM, Sebastian wrote: > Hi, > > What is actually the best practice to replace one item of a list? > > The only way I know feels a bit complicated: > > a =: i. 5 > 0 1 2 3 4 > > > > (2 {. a), 100, (3 }. a) >

[Jprogramming] Replace one item of a list

2014-09-08 Thread Sebastian
Hi, What is actually the best practice to replace one item of a list? The only way I know feels a bit complicated: a =: i. 5 0 1 2 3 4 (2 {. a), 100, (3 }. a) 0 1 100 3 4 Best regards, Sebastian -- For information about

Re: [Jprogramming] Copy & Paste

2014-09-08 Thread Sebastian
Thanks for your help! Best regards Sebastian -- Originalnachricht -- Von: "Devon McCormick" An: "J-programming forum" Gesendet: 29.08.2014 22:43:44 Betreff: Re: [Jprogramming] Copy & Paste Also, if you run jconsole, a C&P executes each line as if they were entered serially. On Fri

Re: [Jprogramming] Copy & Paste

2014-09-08 Thread Sebastian
Thanks for your tips! Best regards Sebastian -- Originalnachricht -- Von: "Joe Bogner" An: programm...@jsoftware.com Gesendet: 29.08.2014 11:48:21 Betreff: Re: [Jprogramming] Copy & Paste In addition to Linda's answer: for quick evaluation of scripts on the clipboard, you can use F8