Haskell - Argument Capture
Just learnt about argument capture in Haskell - I had no clue this existed:
let lss@(l:ls) = [0..10] in
"lss has a head of: " ++ show l ++
", and a length of: " ++ show (length lss)
Result:
"lss has a head of: 0, and a length of: 11"
Note the ‘lss@’ before the pattern match ‘(l:ls)’. This is declaring that I wish to bind the whole list to ‘lss’, the head of the list to ‘l’, and the tail to `ls’.
Nice.