Skip to content
Why is a raven like a writing desk?

Thoughts both confusing and enlightening.

Why is a raven like a writing desk?

Thoughts both confusing and enlightening.

Category: Haskell

Do-notation can be misleading

elbeno, 13 August, 201430 June, 2015

Consider the following function: oddness :: Maybe Int oddness = do let a = Just 1 :: Maybe Int b >= \b -> return b And recall the definition of (>>=) for Maybe: instance Monad Maybe where (Just x) >>= k = k x Nothing >>= _ = Nothing So…

Functional Rainbow

elbeno, 29 December, 200829 December, 2008

Haskell – the videos

elbeno, 9 August, 20071 February, 2015

If you’re one of the approx 3 people left in the world who: knows about functional programming has not yet seen Simon Peyton Jones‘ “A Taste of Haskell” talks from OSCON 2007 I suggest you get over there. It’s quite long, and it gets a bit difficult to follow without…

More on Tree Folds

elbeno, 17 July, 200729 July, 2007

After some thought, I think I have the definitions for left and right fold on a tree: foldrTree :: (a -> b -> b) -> b -> InternalTree a -> b foldrTree f z ILeaf = z foldrTree f z (IBranch a x y) = foldrTree f (f a (foldrTree…

Arboreal Haskell

elbeno, 16 July, 200729 July, 2007

(Chapter 7 of The Haskell School of Expression is about trees.) The first definition is of a tree with values stored only at the leaves, i.e. data Tree a = Leaf a | Branch (Tree a) (Tree a) It then gives a mapTree function (equivalent to map on a list),…

Another Haskell question

elbeno, 10 July, 200729 July, 2007

Which pattern is more efficient? Pattern a: circleSumA :: [Int] -> Int circleSumA (i1 : is) = aux i1 is where aux i [] = i + i1 aux i is = i + aux (head is) (tail is) Pattern b: circleSumB :: [Int] -> Int circleSumB is = sum…

Haskell problem followup

elbeno, 10 July, 200729 July, 2007

Having read a bit of the next chapter and discovered the zipWith function, I now have a higher-order non-recursive solution to the makeChange problem, viz. makeChange1 :: Int -> [Int] -> [Int] makeChange1 amt vs = zipWith div modvs vs where modvs = scanl mod amt vs

Haskell problem

elbeno, 8 July, 200729 July, 2007

Define a function makeChange that, given a nonnegative integer amount and a list of coin denominations, returns a list of the number of coins of each denomination required to make up the amount. For example: makeChange 99 [5,1] => [19,4] i.e. 19 nickels and 4 pennies equals 99 cents. To…

Haskell wibblings

elbeno, 21 May, 200729 July, 2007

Well, this weekend I dived in with Haskell and started to make my way through The Haskell School of Expression. So I’ve been exercising neural pathways that haven’t seen a treadmill in a while, C++ programmer that I am. Overall, it’s been going well, and it’s giving me the feeling…

A Functional Weekend

elbeno, 16 January, 200729 July, 2007

For some time now I’ve been aware of the fact that 12 years’ professional C and C++ programming has moulded my programming thinking habits. This has been brought home particularly in the last 3 years when I’ve been doing quite advanced C++ and therefore reaching the limits of compilers and…

©2026 Why is a raven like a writing desk? | WordPress Theme by SuperbThemes