praxis

Various programming exercises.
Log | Files | Refs

commit ee6bf11cdfe63185ea054ac00c78786347aa35cf
parent 3c47ca8f5a6db7d07a8e6f5ac24a8bd8af24c582
Author: Jared Tobin <jared@jtobin.ca>
Date:   Mon,  9 Jul 2018 07:34:20 +1200

Clean.

Diffstat:
M20180522_floyd/Floyd.hs | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/20180522_floyd/Floyd.hs b/20180522_floyd/Floyd.hs @@ -4,18 +4,17 @@ import Data.List as L (unfoldr) floyd0 :: [[Int]] floyd0 = loop 1 [1..] where - loop n input = - let header = take n input - footer = loop (succ n) (drop n input) + loop size input = + let header = take size input + footer = loop (succ size) (drop size input) in header : footer floyd1 :: [[Int]] floyd1 = L.unfoldr alg (1, 0) where - alg (m, n) = - let lbound = m - ubound = lbound + n + alg (lbound, size) = + let ubound = lbound + size range = [lbound..ubound] - in Just (range, (succ ubound, succ n)) + in Just (range, (succ ubound, succ size)) render :: Show a => [a] -> String render input = case input of