CodeWars Strikes Again - HaskellRank Ep.13

Поділитися
Вставка

КОМЕНТАРІ • 28

  • @Johannes_Kuhn
    @Johannes_Kuhn 5 років тому +13

    You are right, the performance of the site is abysmal.
    But the no IO approach gives some interesting possibilities.
    Currently proof katas are popular (check for example "A + B = B + A? Proof it!") - (ab)using Haskell's type system to write proofs.
    That's imho the killer feature. The ability to not only check a simple input/output model, but to make use of the language.

  • @hansschenker
    @hansschenker Рік тому +3

    You are a crazy experienced Haskeller! Very helpful to see on your way to the solution. You can learn here functional style programming! Thank's for publishing!!

  • @AdamSchelenbergCom
    @AdamSchelenbergCom 5 років тому +9

    Thanks for doing a challange on Codewars. I agree it's a slow platform. But it's great for beginner Haskellers because of the template you get at the start.

  • @wisuthantanong1927
    @wisuthantanong1927 5 років тому +19

    The `trim` function broke my heart 💔, I was expect to learn `Tsoding` magic, not this one.

    • @alphamikeno-shoot1310
      @alphamikeno-shoot1310 5 років тому

      @@noomade Your inefficient solution is still O(N) no?

    • @ne4to777
      @ne4to777 3 роки тому

      @@alphamikeno-shoot1310 , it has ugly rendering, not inefficient.

  • @valentjedi
    @valentjedi 5 років тому +19

    You're penetrating functors and video is still monetized.

  • @Techiesse
    @Techiesse 5 років тому +1

    I'm feeling better with my Haskell capabilities now :). Great video!

  • @TheRodiMaster
    @TheRodiMaster 4 роки тому +3

    One word, "words".

  • @OverG88
    @OverG88 5 років тому +5

    Jesus Christ codewars is slow as a slug. Great video btw!

  • @chromosundrift
    @chromosundrift 4 роки тому +3

    trim = dropWhileEnd isSpace . dropWhile isSpace

    • @EidosGaming
      @EidosGaming 3 роки тому

      Didn't know that function existed! Thanks

  • @badeducation6041
    @badeducation6041 5 років тому +2

    If you have a type of [Maybe Text], then you can directly do the following
    concatMap (fromMaybe " ") = [Just "M", Nothing, Nothing, Just "M", Nothing, Just "M", Just "M", Just "M", Just "M", Just "M"]
    and you get: "M M MMMMM"

  • @DanDart
    @DanDart 5 років тому +2

    I'd have used "Map String Char" maybe...

    • @ishdx9374
      @ishdx9374 4 роки тому +1

      Just (Map String Char)

  • @10e999
    @10e999 5 років тому +2

    Quick question:
    I want to follow your c video game building stream on twitch.
    To understand the project better, I wanted to watch the previous stream videos.
    I checked your twitch channel and notice that the first two videos (about coding physics engine) are not available.
    Could you fix this ?

    • @Tsoding
      @Tsoding  5 років тому +1

      Unfortunately, no. Twitch automatically deletes VODs that are older than 2 months and I can't do anything about it, sorry.

    • @10e999
      @10e999 5 років тому +1

      @@Tsoding Oh. I didn't know that.
      Thank anyway.
      Even though I really appreciate your haskell content, your C stuff is my jam. :)
      Have a great day.

  • @thomasberryhill6318
    @thomasberryhill6318 5 років тому

    Is there a more performant way that 'trim' could be defined?

    • @fintarabg
      @fintarabg 5 років тому +1

      @@Aramizyera23 it's the same thing, though (looking at the source)?

    • @MCFalkenstein
      @MCFalkenstein 5 років тому +1

      @@fintarabg It uses "dropWhileEnd" . I don't know if the size of a string in haskall is known at runtime without walking the whole string (so you could just jump to the end). In any case this is a much more efficient way, since you just look form the back without flipping at all.

    • @fintarabg
      @fintarabg 5 років тому

      @@MCFalkenstein Ah, you are right. I've confused it with takeWhileEnd for some reason.

    • @wisuthantanong1927
      @wisuthantanong1927 5 років тому

      As far as I understand, the performance of trim function might not be too bad because of the `fold fusion` magic. ( I don't technically know the detail, please correct me if I was wrong)

    • @0LoneTech
      @0LoneTech 4 місяці тому

      Since String is [Char], length is O(n). This is one of the reasons more serious code uses other representations like Data.Text (which includes a strip function).

  • @eygs493
    @eygs493 2 роки тому

    Haskell use hash map yes*

  • @MrHatoi
    @MrHatoi 4 роки тому

    2:15 I'm pretty sure hackerrank does the same thing if you don't delete the template every time you do it lol

  • @Eknoma
    @Eknoma 2 роки тому

    I am a bit late, but I am fairly certain Data.List has dropWhileEnd, so your trim could be
    trim = dropWhileEnd isSpace . dropWhile isSpace