From: Michael Orlitzky Date: Sun, 2 May 2010 21:05:15 +0000 (-0400) Subject: Added the octet_from_string function. X-Git-Tag: 0.0.1~77 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=ebe1475e977790ce14eb31e4a75d82e413590bc9;p=hath.git Added the octet_from_string function. --- diff --git a/src/Octet.hs b/src/Octet.hs index e0a4bf6..c40d450 100644 --- a/src/Octet.hs +++ b/src/Octet.hs @@ -46,6 +46,13 @@ octet_from_int x a8 = if (x `mod` 1) > 0 then One else Zero +octet_from_string :: String -> Octet +octet_from_string s = + case (reads s :: [(Int, String)]) of + [] -> Octet.None + x:_ -> octet_from_int (fst x) + + -- The octet with the least possible value. min_octet :: Octet min_octet = Octet Zero Zero Zero Zero Zero Zero Zero Zero