-
Description Create an infinite list of alternating
1
s and0
s, 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
Output:
-
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}