functional.cafe is one of the many independent Mastodon servers you can use to participate in the fediverse.
functional.cafe is an instance for people interested in functional programming and languages.

Server stats:

213
active users

Public

Related: I like how I can write the SpongeBob thingy with less than a tweet in Python.

Public

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('')
Public

(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... 😆

Public

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.