User loginNavigation |
archivesCan referential transparency be bad? (puzzle included)After reading the thread about PL puzzles I decided for a change to design my own puzzle instead of my own PL. How about this - "mirror an immutable binary tree preserving existing sharing"? So in Haskell, I would take this data type: Or I may use StableName, but then I will end up inside IO kitchen sink. To be constructive, I decided to redesign the puzzle so it is a fair game. The full tree of depth n (having 2n-1 nodes) will therefore be compressed to a DAG of n nodes - impressive ratio! Additional points if your code does not create intermediate structures (this is unfair towards PLs without implicit stack, BTW), if it traverses the original tree only once, if it can be reused for other data types, and if you can state it's computational complexity and/or maximum size of the stack (sure, some of these tasks are much harder than others). Matching Objects With PatternsMatching Objects With Patterns. Burak Emir, Martin Odersky, and John Williams.
By Matt Hellige at 2007-01-04 20:01 | Object-Functional | Scala | 17 comments | other blogs | 25101 reads
|
Browse archivesActive forum topics |
Recent comments
22 weeks 12 hours ago
22 weeks 16 hours ago
22 weeks 16 hours ago
44 weeks 1 day ago
48 weeks 3 days ago
50 weeks 1 day ago
50 weeks 1 day ago
1 year 4 days ago
1 year 5 weeks ago
1 year 5 weeks ago