Ad
  • Custom User Avatar

    Please help me understand the replacer function used in the decodeBits function. This syntax is really tripping my mind. I've never seen anything like this so I would like to understand it. For example, it looks to me to be a 3D array: s => [...][...][...].

    It looks like the:

    • first dimension is simply defining an array with 2 objects, one for the replacement spaces and the second the replacement dot and dash.
    • second dimension appears to simply be getting the first character of the matched group, so either a 0 or a 1. But I don't understand what the + symbol is doing there.
    • third dimension is dividing the matched group by the time unit.

    Can you tie all this together for me, or point me in the direction of some reading material so I can wrap my head around this? I don't even know what to search for to google it!

  • Custom User Avatar

    This is my favorite solution I've seen thus far. Very nice and understandable implementation. Clever!

  • Custom User Avatar

    Nice usage of a tail recursive function. Beautiful solution.

  • Custom User Avatar

    Very nice solution!