Skip to content

Exercise - grouping characters #148

Open
@practicalli-johnny

Description

@practicalli-johnny

Given a string "aaabcdddefffff" split apart into continuous groups, i.e., ["aaa" "b" "c" "ddd" "e" "fffff"]?

(partition-by identity "aaabcdddefffff")

(->> (partition-by identity "aaabcdddefffff")
(mapv (partial apply str)))

if seeing partial apply str makes you shudder
(->> (partition-by identity "aaabcdddefffff")
(mapv clojure.string/join))

clojure.string/join has a 1-arity that joins with an empty string, so negates the need to use apply str

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions