Related: I like how I can write the SpongeBob thingy with less than a tweet in Python.
Dunno if I shown this before, but:
import sys
from itertools import cycle
functions = cycle([str.upper, str.lower])
phrase = sys.argv[1]
for char in phrase:
func = next(functions)
print(func(char), end='')
print('')
(Yeah, not checks if you forget to pass the phrase in the command line, but... 192 characters, babeeeee.)
Wondering if I can write the same thing in less than 200 characters in Rust now...
Well, 257 bytes so far and I can't cycle through char::to_uppercase
and char::to_lowercase
'cause they have distinct traits (so I can't build a vector with both). I could write my own wrapper functions, but that would just increase the byte count.