Haskell for Imperative Programmers #20 - Advanced Exercises

แชร์
ฝัง

ความคิดเห็น • 13

  • @aurorazuoris6654
    @aurorazuoris6654 4 ปีที่แล้ว +13

    The third exercise was certainly something! It took me 3 hours but it's pretty cool how far I've come to do this.

    • @santanamalcolm8048
      @santanamalcolm8048 3 ปีที่แล้ว

      You probably dont care but if you are bored like me atm you can stream all of the latest movies on InstaFlixxer. I've been streaming with my girlfriend recently xD

    • @jamesmajor5978
      @jamesmajor5978 3 ปีที่แล้ว

      @Santana Malcolm Yea, I've been watching on InstaFlixxer for years myself :)

  • @ronaldc8634
    @ronaldc8634 3 ปีที่แล้ว +3

    Can't believe how elegant the solution for the infinite tuple list turned out (though I realized you don't need the dollar signs, there). Here's mine:
    infiniteTupleTree :: Tree (Integer, Integer)
    infiniteTupleTree = Node (0, 0) (mapTree left t) (mapTree right t)
    where
    t = infiniteTupleTree
    (left, right) = ((1,0), (0,1))
    mapTree (x, y) (Node (l, r) lt rt) = Node (l + x, r + y) (f lt) (f rt)
    where
    f = mapTree (x, y)

  • @pasdenom.9062
    @pasdenom.9062 4 ปีที่แล้ว +6

    At this point we finally do a bit of "real" tasks, at least with the third exercise. That's what is really painful with Haskell, sadly: tutorials spend too much time on mathematical-ish things. That was the case here too, even if your videos are just GREAT (a big thanks to you, btw). You definitively have been way more efficient and straightforward than maybe all the documents I encountered so far on the subject, and it is entertaining to watch even without doing the exercises. I really want to have this for other languages, too!
    Maybe Haskell could be more attractive with tutorials based on other languages tutorials, dunno.

  • @avrilavignerockz
    @avrilavignerockz 2 ปีที่แล้ว

    Thank you for this. I really like your teaching , I hope you make videos on other languages too

  • @cuongbruce
    @cuongbruce 2 ปีที่แล้ว +2

    Hi Phillipp, thanks for the video man. But I think the function 'findStrings' exercise 3 might not be true in some cases, mainly because of "ftext = filter (\x -> isLetter x || isSpace x) text". For example text = "lo_rem" after filter it becomes 'lorem', so mistaken the word lorem exist?

  • @davidyanceyjr
    @davidyanceyjr 4 ปีที่แล้ว +1

    Great Videos.

  • @bcmpinc
    @bcmpinc 2 ปีที่แล้ว

    A few functions that I found useful for exercise #3 but have not yet been introduced:
    - fmap, which lifts a function f::a->b to create (fmap f)::IO a->IO b, similar to how (map f)::[a]->[b] (Note: it's actually Functor rather than IO here, but IO is a Functor)
    - sequence :: [IO a] -> IO [a], which executes the IO actions in sequence and returns an IO action containing a list of the results.

    • @MrDiverXHD
      @MrDiverXHD 8 หลายเดือนก่อน

      Would you like to explain why these would be useful ? Or where ?

  • @user-sj7lk5lg3x
    @user-sj7lk5lg3x 10 หลายเดือนก่อน

    why is a `types` variable necessary if the type can be put in the function signature ? eg. prop_IIS :: [Int] -> Property

  • @geogreenmanu
    @geogreenmanu 3 ปีที่แล้ว

    forEach :: Monad m => (t -> m a) -> [t] -> m ()
    forEach f (x : xs) = do
    f x
    forEach f xs
    forEach _ [] = return ()
    I can't seem to get the idea of Anonymous bind. It seems related to the above function. We need to apply f to a (Monad a ) but we don't care about the return value of forEach and return value of applying f. Is that it? Can I think of Anonymous bind as forEach? like in scala?

    • @philipphagenlocher
      @philipphagenlocher  3 ปีที่แล้ว +1

      The anon. bind is just like the regular bind but ignoring the value that the bind receives. Think of putStrLn. What will be returned from printing? The answer is: nothing (the placeholder for that is the empty tuple). Do we have to save that value for later? No! So something like "val