code
20 September 2008 | 0 Comments
To explain this, imagine you are designing a type Wrapper<T>, which is just a simple wrapper around a type T. class Wrapper<T> { T value; public Wrapper(T theObject) { value = theObject; } // Some other methods… } Now, since this is a just a wrapper around some type T, we would like to implement [...]
Tagged in C#, code, Haskell, idea
code
1 May 2008 | 1 Comment
Prompted by A Scala Quine, here’s a nice one in Haskell that I haven’t seen anywhere else… main = (putStr . ap (++) show) "main = (putStr . ap (++) show) " Edit: I have found it somewhere else Here, to be exact.
Tagged in code, Haskell, quine, snippet
replies
27 February 2008 | 0 Comments
Douglas, you’re not alone. import Data.List (sortBy) import Data.Function (on) import Data.Maybe (mapMaybe) import Control.Monad.Instances gizzabuzz pairs combiner = zipWith ($) (cycle funcs) [1..] where sortedPairs = sortBy (compare `on` fst) pairs funcs = map (\n -> display $ mapMaybe (filterOut n) sortedPairs) [1..foldr1 lcm $ map fst $ sortedPairs] display [] = show [...]
Tagged in fizzbuzz, Haskell, horrid, humour, overengineered, Programming
replies
23 January 2008 | 7 Comments
Our target for this exercise is “Things that other languages should take from Lisp”. Bignum support In Scheme and Common Lisp, by default you can’t overflow an integer… Prelude> fac n = product [2..n] Prelude> fac 100 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582 51185210916864000000000000000000000000 In Common Lisp, you can force your code to use fixed-size numbers (fixnums) for efficiency… Prelude> [...]
Tagged in comparison, Haskell, Links, lisp