functional-koans / clojure-koans

A set of exercises for learning Clojure
3.74k stars 2.14k forks source link

src/koans/21_partition.clj: correct meditation doc #102

Closed puhrez closed 8 years ago

puhrez commented 8 years ago

The meditation was misleading because calling (partition-all 3 (range 5)) returns ((0 1 2) (3 4)) results in sequences having <=3 elements , not strictly less than.

trptcolin commented 8 years ago

Yeah I agree we can improve things here.

How would you feel about something like "You can use partition-all to make sure you get all of the elements" or something like that, to emphasize getting all the elements from the input collection. I'm wondering if that'd feel more conversational and less computer-y than "less than or equal to". What do you think?

puhrez commented 8 years ago

hmm I'm not sure about conversional given that the intended voice is meditational which I feel is achieved with "less than or equal to" (probably because I read it in a zen voice haha). Also all in this context is kinda dependent on n and the availability of n elements in the current partition, so it would remain misleading.

Perhaps, "at most"? it expresses "<=" and sounds slightly elevated: "You can use partition-all to also get partitions with at most n elements"

@trptcolin thoughts?

trptcolin commented 8 years ago

Thanks for pointing this out @xbs13 - I've thought about this a few times and I think I've got a good solution to this. Going to merge your contribution and then make a few tweaks afterwards.

:+1: