Re: [stack] disallowing recursive definitions
"Christopher Diggins" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Mar 1, 2008 at 8:51 AM, Stevan Apter <[email protected]> wrote: > i'm still puzzled why authors of concatenative languages like cat and factor > have resisted the incorporation of array primitives into their languages. Map, filter, fold, etc. are all part of the core Cat language. I consider all of these array primitives. The Cat concept of list is more or less analgous to an array, but is agnostic about implementation details. An implementation is left to its own devices as to what the performance characteristics of lists are. Sorry its not more clear in the current documentation. >in > the admittedly trivial examples below, why not write > > 1+til / applied to n generates 0..n-1, then add 1 In Cat n [1 +] map > or > > 1 drop til 1+ / add 1 to n, generate 0..n, then drop the first n [1] drop > instead of either looping or recursion? Sure completely valid. Of course sometimes loops are fun to have outside of the context of a list. > my sense is that programmers (and language designers) *still* do not > appreciate > the power of array programming. Well I know that Slava (the author of Factor) does, and I'd like to feel that I do. Its not really fair to single us out in this. > here's an example i posted the other day on > comp.lang.functional, a general sudoku solver written in q by arthur > whitney. > for readability, i've replaced the case statement of q ($[x;y;z]) with > if-then- > else pseudocode. > > f:{if all x then enlist x else raze f each amend[x;i]each where 27=x[raze p > i:x find 0]find til 10]} > > note the explicit tail-recursion on 'f' in the else clause. also note that > this is > the standard algorithm used in sudoku solvers written in java, python, ruby, > ocaml, > &c. compression is achieved through the use of a handlful of array > primitives > (til, find, raze, where, all), one iterator (each), a primitive for updating > positions of an array (amend), and a single primitive extended from scalars > to > arrays (=). I'll have to look more closely at this (I don't know what "til", "find", "raze", "where", "all", "each", and "amend" do). But it should be easy to implement something similar. Nonetheless, your original point is still valid that some more array processing primitives would be valuable in Cat. I'll add some to the specification. - Christopher