Re: [Jprogramming] Existing a Tacit

2014-08-25 Thread Raul Miller
Meanwhile http://users.ece.utexas.edu/~adnan/pike.html ;) Thanks, -- Raul On Tue, Aug 26, 2014 at 12:42 AM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > to expand on what you are saying, > >timespacex '+/`0:@.([: +./ 0 = ]) 0,~ >: i.1e5' > 0.00329024 3.28512e6 >

Re: [Jprogramming] Existing a Tacit

2014-08-25 Thread 'Pascal Jasmin' via Programming
to expand on what you are saying,    timespacex '+/`0:@.([: +./ 0 = ]) 0,~ >: i.1e5' 0.00329024 3.28512e6    timespacex '+`0:@.(0 = *)/ 0,~ >: i.1e5'  0.0532716 2.10253e6 the first expression sees if any item is 0, and if not, it does +/ else it returns 0.  It is 20 times faster than 2nd exp

Re: [Jprogramming] Adler-32

2014-08-25 Thread 'Pascal Jasmin' via Programming
Can't say that I like any of their code or examples. In J, In addition to boxscan there is also ^: and lexical closures http://www.jsoftware.com/jwiki/PascalJasmin/nonads%20revisited / is very powerful though    |. >: i.10 10 9 8 7 6 5 4 3 2 1 applying */ to the above not only gives the fact

Re: [Jprogramming] Existing a Tacit

2014-08-25 Thread Raul Miller
The best technique for avoiding work is to not specify it in the first place. @. does work, of course. :: is another option. ^: is another option. Often, though, it's better to instead specify an operation which does the right thing instead of "exiting early". The reason for this has to do with

[Jprogramming] Existing a Tacit

2014-08-25 Thread William Szuch
What techniques or methods can be used to exit a tacit at multiple points depending on the results of the data flow through the tacit ?. In an explicit this is achieved by using the control statement "return." a multiple times. A simple case for one exit would be to use something like: f1

Re: [Jprogramming] Adler-32

2014-08-25 Thread Raul Miller
p.s. you can claim that you know J very well. ;) Thanks, -- Raul On Mon, Aug 25, 2014 at 8:35 PM, Jose Mario Quintana wrote: > Pascal wrote: > " > use of terms like "recursion with tail call optimization" come from lisp > fold implementations where in order to avoid stack growth/exhaustion (

Re: [Jprogramming] Adler-32

2014-08-25 Thread Raul Miller
http://weblambdazero.blogspot.com/2010/07/advanced-recursion-in-newlisp.html looks like it is describing this: memoize=: M. http://www.integralist.co.uk/posts/understanding-recursion-in-functional-javascript-programming/#the-solution looks like it is describing this: trampoline=:3 :0 try.

Re: [Jprogramming] Adler-32

2014-08-25 Thread Jose Mario Quintana
Pascal wrote: " use of terms like "recursion with tail call optimization" come from lisp fold implementations where in order to avoid stack growth/exhaustion (/ avoids such stack abuse btw), you need to pass any accumulator (state between function calls) as a parameter to the function. boxscan bas

Re: [Jprogramming] Adler-32

2014-08-25 Thread Raul Miller
Take a look at Jose's also... even more tacit (though not quite the same thing). The essential trick is to convert the "verb on the right" to an adverb of the form @v which lets it work just fine in an adverb train. The "not quite the same" aspect includes reversing the order of the list. Thanks

Re: [Jprogramming] Adler-32

2014-08-25 Thread 'Pascal Jasmin' via Programming
though I found it tricky to write ad32 without boxes due to fills, I have written essentially the same as your last line: reduce =: 1 : (':'; 'u boxscan (<"_1 x), < y')  except yours is better because its tacit.      (i.5) + reduce (i.10) + reduce 5 0 60 55 but manipulating the boxes directl

Re: [Jprogramming] Adler-32

2014-08-25 Thread Raul Miller
On Mon, Aug 25, 2014 at 2:40 PM, 'Pascal Jasmin' via Programming wrote: > boxscan can use any list of arguments as the x, and appends any > shape as the y, as long x u y results in a shape "compatible with > y" (more accurately compatible with future applications of x u > result . boxscan can use

Re: [Jprogramming] Adler-32

2014-08-25 Thread 'Pascal Jasmin' via Programming
/ and boxscan are indeed fold and reduce in other languages.  The lisp implementations probably the easiest to understand. The big difference between / and boxscan is that / applied to a list implies a requirement that all items in the list are the same shape.  boxscan can use any list of argum

Re: [Jprogramming] Adler-32

2014-08-25 Thread Raul Miller
I have a nitpick with your phrasing here. Instead of saying "... use / recursively... (tail call optimization)" I think you should say something else. Mind you, I'm not quite sure what you should say. And, it's a nice clever bit of code. And here's another example of how I might use the concept

Re: [Jprogramming] Adler-32

2014-08-25 Thread 'Pascal Jasmin' via Programming
I was curious in making a chunked version of running sum for the algorithmic savings of doing 1 modulo expression per group, but also working with packet groups, or "bytes so far". Randdata =. 1e7 ?@:$ 256 boxscan =: ((&.>)/)(>@:)  an explicit version for argument to boxscan: runsum =: 4 : 0