Skip to main content
added explanation
Source Link
Laikoni
  • 26.3k
  • 6
  • 52
  • 115

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Explanation:

In non-pointfree notation and using concatMap instead of =<<, this becomes

f s = concatMap(\c-> show c ++ ":")s ++ "[]"

Given a string s, we map each char c to a string "'c':" using the show function which returns a string representation of most Haskell types. Those strings are concatenated and a final [] is appended.

Although not requested by the challenge, this answer even works with proper escaping, because show takes care of it: f "'" yields "'\\'':[]".

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Explanation:

In non-pointfree notation and using concatMap instead of =<<, this becomes

f s = concatMap(\c-> show c ++ ":")s ++ "[]"

Given a string s, we map each char c to a string "'c':" using the show function which returns a string representation of most Haskell types. Those strings are concatenated and a final [] is appended.

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Explanation:

In non-pointfree notation and using concatMap instead of =<<, this becomes

f s = concatMap(\c-> show c ++ ":")s ++ "[]"

Given a string s, we map each char c to a string "'c':" using the show function which returns a string representation of most Haskell types. Those strings are concatenated and a final [] is appended.

Although not requested by the challenge, this answer even works with proper escaping, because show takes care of it: f "'" yields "'\\'':[]".

added explanation
Source Link
Laikoni
  • 26.3k
  • 6
  • 52
  • 115

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Explanation:

In non-pointfree notation and using concatMap instead of =<<, this becomes

f s = concatMap(\c-> show c ++ ":")s ++ "[]"

Given a string s, we map each char c to a string "'c':" using the show function which returns a string representation of most Haskell types. Those strings are concatenated and a final [] is appended.

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!

Explanation:

In non-pointfree notation and using concatMap instead of =<<, this becomes

f s = concatMap(\c-> show c ++ ":")s ++ "[]"

Given a string s, we map each char c to a string "'c':" using the show function which returns a string representation of most Haskell types. Those strings are concatenated and a final [] is appended.

Source Link
Laikoni
  • 26.3k
  • 6
  • 52
  • 115

Haskell, 26 bytes

(++"[]").((++":").show=<<)

Try it online!