0

When I try to map over a string, I get:

Exception: Sequence does not respond to 'map'

Apparently, Io does not implement a map method for sequences. So how can I convert a string sequence into a list of characters?

mcandre
  • 22,868
  • 20
  • 88
  • 147
  • possible duplicate of [How do I convert a string to a list in Io?](http://stackoverflow.com/questions/4255123/how-do-i-convert-a-string-to-a-list-in-io) – mcandre Oct 10 '11 at 05:24

1 Answers1

0

Io doesn't currently have a Sequence asList method, but one can easily be added.

Range

s := "abc"

# From StackOverflow
# http://stackoverflow.com/questions/4255123/how-do-i-convert-a-string-to-a-list-in-io/4256258#4256258
Sequence asList := method(
    result := list()
    self foreach(x,
        result append(x)
    )
)

s asList map(c,
   "Char: #{c}" interpolate println
)

Output:

Char: a
Char: b
Char: c
mcandre
  • 22,868
  • 20
  • 88
  • 147