User loginNavigation |
archivesFilter-Reduce OptimizationThis must be well-know amongst functional programming researchers, but I kind of stumbled upon it by accident when studying Joy. Consider the following program to count even numbers: define count_evens = [2 mod 0 neq] filter 0 [inc] reduce So for those new to Joy, every program/function takes it parameter on the stack, and pushes its results onto the stack. Here is a brief explanation of the operators:
The program I showed takes a list on the stack, filters the list for only even numbers, and then counts them using a reduce function. Assuming you are following me so far, this program can be rewritten as follows (caveat: I'm doing this off the top of my head so I could have made a mistake in syntax): def count_evens_1 = 0 [2 mod 0 eq [inc] [] if] reduce What I've done here is eliminate the unneccessary filter operation and "folded" it (pun intended) into the reduce operation. My observation when working with Joy is that this optimization is trivial to automate. So my question to the group is: is this a well known optimization, and if so, is it as easily applied in other functional languages? For those whose curiosity has been piqued, I'm researching the viability of using a Joy dialect as an intermediate language. Functional Relational Programming: Out of the tar pitIn a similar vein to John Carter's recent submission, here's an attempt to attack the complexity problem: Out of the tar pit
They basically advocate minimising mutable state, moving any mutable state that remains into relations, and specifying the behaviour (i.e. manipulation of relational data) in a declarative/logical/purely-functional language. Pros: the first half of the paper is a reasonable review of the types and causes of complexity in software. Cons: lack of any implementation, other than a Scheme prototype of the relational bits, I think (see footnote 25). No source code. Lack of detail about interfacing with external systems. Here's a link to Ben Moseley's FRP page, where you can find the paper, plus presentation slides and a discussion group. Proofs are Programs: 19th Century Logic and 21st Century ComputingProofs are Programs: 19th Century Logic and 21st Century Computing
This paper by Philip Wadler was a Dr Dobbs article in 2000 and has a matching a Netcast interview. For more of Wadler's writings along these lines check out his History of Logic and Programming Languages paper collection. edit: fixed the dr dobbs article link By shapr at 2006-05-02 17:38 | History | Theory | Type Theory | 41 comments | other blogs | 17502 reads
|
Browse archivesActive forum topics |
Recent comments
21 weeks 6 days ago
21 weeks 6 days ago
21 weeks 6 days ago
44 weeks 1 day ago
48 weeks 3 days ago
50 weeks 7 hours ago
50 weeks 7 hours ago
1 year 4 days ago
1 year 5 weeks ago
1 year 5 weeks ago