Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 5064 days ago | link | parent

intersperse still seems weirder than map , because map just returns the type of its args, while intersperse is checking the type of elements inside its list arg.

Yeah, that's one reason I'm not sure I agree with this proposal. Fundamentally, I don't like the idea that (intersperse x (list a b c)) would return (list a x b x c) sometimes and (+ a x b x c) others.

If "string:intersperse" is common enough to be a standalone utility with a shorter name, I'd probably name it after PHP's implode(). I'd probably make it use '+ too, so that it could be used to construct lists and custom types of sequence:

  (def implode (first between seq)
    (apply + first (intersperse between seq)))
  
  (implode "?" '& ...)
  (implode "" "\n" ...)
Using '+ instead of hardcoding 'string makes less sense if you have '+ dispatch on the type of the last argument. But hey, I'm a fan of dispatching on the first arg anyway. ;)

This made me also focus on the fact that testify is actually an english word - and arc is misusing it.

How about 'checkify? ^_^ I don't actually mind word misuse, but I do kinda like the idea of reserving the term "test" for unit tests, and I suppose there are even contexts where 'testify could be used for its English meaning:

  - assertions
  - debugger interaction
  - proofs
  - simulations of belief, knowledge, perception, persuasion, etc.
  - generally, status reports, contracts, and sanity checks registered
      with some surrounding framework or compiler


1 point by akkartik 5064 days ago | link

Oh I like implode, thanks. Especially if it's used in this sense in another language, that makes it closer to 'prime real estate'.

-----