Talk:Il

From Esolang
Jump to navigation Jump to search

This page is a discussion of esolang Il, not a dating site or anything like that.
This is where you share your opinion about Il. Or add contribution to this.

just other's opinions about esolang

Just increment and decrement... Iloveunicorns (talk) 10:55, 16 September 2025 (UTC)


WHO CAN WRITE SHORTEST INTERPRETER???

i=p=0;c=input()+" "
for x in c:exec({"I":"i+=1","l":"i-=1"}.get(x,"i")+";p+=1")if c[p+1:]!=""else print(i)

tried my best

User:Gaham (Discord:mrglebsun)


By abstracting the summation and using a dispatch dictionary which builds intermediate integers instead of code snippets, we can write a single-stage function:
lambda s:sum({"I":1,"l":-1}[c] for c in s)
Some of the existing interpreters don't care about invalid inputs. If invalid inputs or comments are a serious concern then we can use the .get() method of dictionaries:
lambda s:sum({"I":1,"l":-1}.get(c,0) for c in s)
We can apply directly to input() for a one-liner that can be invoked with python3 -c:
print(sum({"I":1,"l":-1}.get(c,0) for c in input()))
This doesn't appear to get shorter when using map() or the functools or operator modules, although I invite golfers to keep trying. The secret insight is that Il admits a monoid! Corbin (talk) 15:53, 17 September 2025 (UTC)
clever
User:Gaham (Discord:mrglebsun)

For the one that doesn't care about invalid inputs, the dictionary can be replaced with a slightly smaller expression to get lambda s:sum(ord(c)%2*2-1 for c in s). I might try seeing how other esolangs do later, I think some of them could make a ridiculously short interpreter. –PkmnQ (talk) 01:43, 18 September 2025 (UTC)