Ad
  • Custom User Avatar
  • Custom User Avatar

    This changes the array as well.

  • Custom User Avatar
  • Custom User Avatar

    Not a kata issue.

  • Custom User Avatar

    Help us help you. At the time of writing, this kata is available in eight languages, each with their own tests.

    Specify which language.

    If you're talking about the Example Tests, you may have to write them yourself.

    Closing.

  • Custom User Avatar

    Changed the description and added sample tests to eliminate the BS-factor

  • Custom User Avatar

    Your sentence doesn't make much sense, and it isn't really an issue.

    Anyways, to properly compare objects and arrays you should use Test.assertDeepEquals (because, as every CS 101 lessons will tell you, object reference and object content are two totally different things.)

  • Default User Avatar

    this is what I had:
    Pressing 'run examples' gives errors like: 'expected [1,2] but got [1,2]'.
    But pressing 'attempt' gives tests passed!

  • Custom User Avatar

    Aaaand the kata was ported to Haskell. So I could port my solution right back, and d*mn if it doesn't look like real Haskell.

  • Custom User Avatar

    Higher order functions FTW.

    Seriously, I'm not going to explain it in detail. Maybe one day you'll figure it out by yourself, and the light will be blinding. :P (After I wrote this, it was for me.)

    Three things to keep in mind.

    • The last of same definitions stands. So the second Function.on and the third sumPPG are actually in use. (I needed the earlier definitions to make things clear to myself.)
    • Both Function.on and plus return functions.
    • The second and third sumPPGs are identical. The third definition is what is called point free; it does not mention its arguments (it still has them though). This goes back to point two: plus.on returns a function, so I can define sumPPG by assigning it plus.on().

    The idea for this comes from Haskell, which I am just learning still myself; I recognised a pattern with on and figured it out by coding it myself. This took me a while!

    extract is curried, another idea from Haskell (which itself takes it from Lambda calculus), which allows partial application and point free style.

    Yes, there is a whole lot happening here. It's a generalised (you could feed it more than two arguments, and it'd still work as you'd expect), rather advanced solution to a quite simple exercise. Too much to explain really. Which is why I don't. Apologies for that, but I just don't know where to start and I'd need to explain too many meta things.

  • Custom User Avatar

    you are right! https://www.youtube.com/watch?v=Pkyy57iMaB0 , let me change that. And by the way the iron throne it's more importan than be the king of the north :P

  • Default User Avatar

    Main motto is to convert both sides of equation to same format. So either toUpperCase() or toLowerCase() will do.

  • Default User Avatar

    Thanks, you are right. I rushed a sloppy solution with unintended global variable out. I have updated.

  • Default User Avatar

    Just playing around. The solution to this kata is very simple so I wanted to make it complex.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution