Slices of collections are themselves places, and they can be decomposed further into even finer places. In Common Lisp the subseq function describes such places: (setf (subseq coll start end) slice). Injective functions have an in degree regularity of one, which means that they are trivial place forms. As such, the original programming idiom can be described as a process that moves an object to a place, runs some functions, and then moves back to the starting place.
Another Programming Idiom You've Never Heard Of
11–20 of 35 posts
Re: Another Programming Idiom You've Never Heard Of
#12Oh look, you just invented array slices! https://en.wikipedia.org/wiki/Array_slicing
Re: Another Programming Idiom You've Never Heard Of
#13Oh look, you just invented array slices! https://en.wikipedia.org/wiki/Array_slicing
It's one thing to say, "yeah, I can kinda do this in [language]", it's quite another when your whole language is based on it, as the APL family are. If you can do array slicing in parallel, you can work with permutation vectors rather than sorts (as he notes), and guess what? The same idiom works for relational joins, among many other things. (The killer app for Q, kdb+, is an in-memory, column oriented relational database. NoSQL, before it was cool.)
Re: Another Programming Idiom You've Never Heard Of
#14Oh look, you just invented array slices! https://en.wikipedia.org/wiki/Array_slicing
Guy who doesn't understand general statements and statistics: "Your title is wrong, _I have_ heard of that idiom". A different guy with the same deficiency: "Wrong, it's a common idiom in (list of obscure languages)". Plus: array slicing, in 95% of the languages mentioned (and 99% of common languages) is NOT what he talks about. It just returns a sub-array and it only takes an uper/lower bound.
Re: Another Programming Idiom You've Never Heard Of
#15> 6 5 4 3 2 1 0 { 10 5 9 6 20 17 1
Stored in an array? Because if it is, when I do this:
> 2 3 4 5 6 { 10 5 9 6 20 17 1
Won't I have to rearrange the whole array? (deleting two of the index parts)
Re: Another Programming Idiom You've Never Heard Of
#16 (map [1 2 3 4 5 6 7 8 9 10] [0 3 4])
=> (1 4 5)Re: Another Programming Idiom You've Never Heard Of
#17This seems cool but I have a question. Is this: > 6 5 4 3 2 1 0 { 10 5 9 6 20 17 1 Stored in an array? Because if it is, when I do this: > 2 3 4 5 6 { 10 5 9 6 20 17 1 Won't I have to rearrange the whole array? (deleting two of the index parts)
* It's now open-source at https://github.com/openj/core, but I have a hard time following their C style -- it's legal C, but written like J.
APLs have memory allocators that are designed with arrays in mind, making this less expensive than you might expect. See this post I wrote about the memory management for Kona (https://github.com/kevinlawler/kona/), an open-source implementation of K: https://groups.google.com/forum/#!topic/kona-dev/fs5GoSBtF3Y... .
Re: Another Programming Idiom You've Never Heard Of
#18Re: Another Programming Idiom You've Never Heard Of
#19Clojure can do this as well without requiring any special syntax or function because all sequence are funcallable: (map [1 2 3 4 5 6 7 8 9 10] [0 3 4]) => (1 4 5)