In Julia, these examples of a string being treated as an iterator (delivering characters) work:
number = "1234"
notnumber = "123z"
isgood = all(isdigit, number) # true
isobad = all(isdigit, notnumber) # false
isgood = mapreduce(isdigit, &, number) # also true
isbad = mapreduce(isdigit, &, notnumber) # also false
myhex = mapreduce(codepoint, &, number) # 0x00000030
avector = map(codecode, collect(number))
but this does not work, despite isdigit() and codepoint() having a very similar signatures:
avector = map(codepoint, number) # causes error
Why is it sometimes necessary to use collect() on the string? If the answer is because all() and mapreduce() take iter and map() takes collection, please explain the distinction?
Is using collect() with map() wrong, because it leads to longer execution times or greater memory usage?