Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2017 21:57

Revisions

  1. @invalid-email-address Anonymous created this gist Oct 25, 2017.
    19 changes: 19 additions & 0 deletions sb.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import Data.Ratio
    loop x a = do
    print a
    let (l,r) = sb a
    let (_,(d,e)) = l
    case compare (fromRational (d%e)) x of
    EQ -> return $ d%e
    GT -> loop x l
    LT -> loop x r
    sb((x,y),(z,w))=(a,b)
    where a = ((x,y),c)
    b= (c,(z,w))
    c= (z+x,y+w)
    main = do
    let a = (0,1)
    let b = (1,0)
    let r = (a,b)
    loop pi r >>= print