Move History

Fork Selected
  • Description

    Create an infinite list of alternating 1s and 0s, like so:

    1:0:1:0:....
    
    Code
    module Knot where
    
    import Debug.Trace
    
    onesAndZeroes :: Num a => [a]
    onesAndZeroes =
      let x = 1 : y
          y = 0 : x
       in x
    
    Test Cases
    module ExampleSpec where
    -- Tests can be written using Hspec http://hspec.github.io/
    -- Replace this with your own tests.
    
    import Test.Hspec
    import Knot
    
    -- `spec` of type `Spec` must exist
    spec :: Spec
    spec = do
        describe "Some taken values are correct" $ do
            it "take some values" $ do
                (take 4 onesAndZeroes) `shouldBe` ([1, 0, 1, 0])
    -- the following line is optional for 8.2
    main = hspec spec