Skip to content

Latest commit

 

History

History
74 lines (70 loc) · 1.52 KB

ch08.adoc

File metadata and controls

74 lines (70 loc) · 1.52 KB

8 Recursion

8.2 Factorial

Intermission: Exercise

link:ch08_8.2_0.hs[role=include]

8.6 Chapter Exercises

Review of types

  1. d) [[Bool]] is type of [[True, False], [True, True], [False, True]]

  2. b) [[3 == 3], [6 > 5], [3 < 4]] is the same type as [[True, False], [True, True], [False, True]]

  3. d) all of the above

    func :: [a] -> [a] -> [a]
    func x y = x ++ y
  4. b) func "Hello" "World"

Reviewing currying

link:ch08_8.6_0.hs[role=include]
  1. value of appedCatty "woohoo!" is "woops mrow woohoo!"

  2. value of frappe "1" is "1 mrow haha"

  3. value of frappe (appedCatty "2") is woops mrow 2 mrow haha"

  4. value of appedCatty (frappe "blue") is `"woops mrow blue mrow haha"

  5. value of cattyConny (frappe "pink") (cattyConny "green" (appedCatty "blue")) is "pink mrow haha mrow green mrow woops mrow blue"

  6. value of cattyConny (flippy "Pugs" "are") "awesome" is "are mrow Pugs mrow awesome"

Recursion

  1. step of dividedBy 15 2

    link:ch08_8.6_1.hs[role=include]
    link:ch08_8.6_2.hs[role=include]
  2. recursive sum function

    link:ch08_8.6_3.hs[role=include]
  3. recursive multiplication

    link:ch08_8.6_4.hs[role=include]

Fixing dividedBy

Type of divideBy changed to match DividedResult.

link:ch08_8.6_5_1.hs[role=include]

McCarthy 91 function

link:ch08_8.6_6.hs[role=include]

Numbers into words

link:ch08_8.6_7.hs[role=include]