Skip to content

Instantly share code, notes, and snippets.

@cppxor2arr
Last active June 19, 2018 12:01

Revisions

  1. cppxor2arr revised this gist Jun 19, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion seq_dif.hs
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    f :: Num a => [a] -> [a]
    f :: Num a => [a] -> [a]
    f [] = []
    f [x] = []
    f [x1,x2] = [x2-x1]
    f (x1:x2:xs) = x2-x1:f (x2:xs)
  2. cppxor2arr revised this gist Jun 13, 2018. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions seq_dif.hs
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,3 @@
    main :: IO()
    main = do
    print . f $ map sqrt [1..20]

    f :: Num a => [a] -> [a]
    f [x1,x2] = [x2-x1]
    f (x1:x2:xs) = x2-x1:f (x2:xs)
    f _ = []
    f (x1:x2:xs) = x2-x1:f (x2:xs)
  3. cppxor2arr created this gist Jun 13, 2018.
    8 changes: 8 additions & 0 deletions seq_dif.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    main :: IO()
    main = do
    print . f $ map sqrt [1..20]

    f :: Num a => [a] -> [a]
    f [x1,x2] = [x2-x1]
    f (x1:x2:xs) = x2-x1:f (x2:xs)
    f _ = []