Grasping `all-the-apples-at-once' › 解法样本 Sample solutions › Clojure (Group I) [#277]

(->> "aaaabbbcca"
     (partition-by identity)
     (map (juxt (comp str first) count)))

提交者还提供了另一个解法:“有点繁琐,但更清晰”:
(for [p (partition-by identity "aaaabbbcca" )]
  [(-> p first str) (count p)])
The submitter also gave another solution, ``a bit chattier but also more legible:''

值得注意的是, comp 函数组合 ( functional composition ) ,而 juxt 粗略的类型是 (a -> b * a -> c) -> a -> (b * c),这是一个组合子,它接收一个函数二元组和一个值,对该值应用两个函数,然后返回由这两个函数的返回值组成的元组。
It is worth noting that comp is the functional composition, and juxt, with the rough type (a->b * a->c) -> a -> (b * c), is the combinator that takes a tuple of functions and a value, applies each function to it and returns the results as a tuple.