FP 9 - Exercises On Recursion

Поделиться
HTML-код
  • Опубликовано: 6 ноя 2024

Комментарии • 9

  • @alejandrogomez5419
    @alejandrogomez5419 8 месяцев назад +1

    this is the most elegant merge sort implementation i've ever seen. just, wow!

  • @DaanRosendal
    @DaanRosendal 2 месяца назад

    I really enjoyed solving the exercises, thank you for creating this awesome playlist! A small correction at 8:05, `replicate 3 'b'` actually returns "bbb" as opposed to ['b','b','b']

    • @haskellhutt
      @haskellhutt  2 месяца назад +1

      In Haskell a string is a list of characters, so "bbb" is just a shorthand for ['b','b','b'].

  • @0LoneTech
    @0LoneTech 8 месяцев назад +2

    Bonus Prelude function:
    splitAt :: Int -> [a] -> ([a], [a])

  • @AndriusKaliacius
    @AndriusKaliacius 6 месяцев назад +1

    Wow, that's brilliant! Thank you so much for sharing.

  • @dangquocbao9504
    @dangquocbao9504 7 месяцев назад

    Wonderful lecture. Thank you very much.

  • @davidhand9721
    @davidhand9721 7 месяцев назад

    Can't we write a case like:
    and [] = True
    and (False:bs) = False
    and (True:bs) = and bs

    • @haskellhutt
      @haskellhutt  7 месяцев назад

      In this video the recommendation is to start out with the simplest cases for each kind of type, which for lists means just matching on empty and non-empty lists. The patterns you've used above also match on the first logical value, so are a nested pattern. This is the kind of thing you could do in the final simplification step if you wanted. But personally in this case I'd prefer to just write "and (b:bs) = b && and bs" in the non-empty list case, as it's then clear it's an example of foldr.