From ebe1475e977790ce14eb31e4a75d82e413590bc9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 2 May 2010 17:05:15 -0400 Subject: [PATCH] Added the octet_from_string function. --- src/Octet.hs | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.43.2