Silly Python riddle
>>> f = lambda: g((yield))
>>> f()
<generator object <lambda> at 0x00B50828>
I'm not sure, why you think the value of the lambda function is thrown away. The lambda function returns a generator object. The function body of a generator is generally not executed until you call .next() on it, so that's why you don't get a NameError instantly. Also the value, that you .send() into the generator is not thrown away either. In your example the generator just runs into an exception before it goes into a state in which it would accept a .send() call. Just consider this modified example:
>>> f=lambda: (yield) >>> gen=f() >>> gen.next() >>> gen.send('foobar') 'foobar'I had this (with 8 characters):
giving:);g=(intf = lambda: g();g=(int) f() -> 0I haven't been following the thread, but Ram posted the same riddle on Python-IL mailing list a few days ago. You can see the discussion there.
http://hamakor.org.il/pipermail/python-il/2011-December/thre...
"""At 12 characters, this is definitely not the shortest, but it is a totally different approach than the other solutions:
>>> f = lambda: g()if 0 else(1) >>> f() 1I was going to attempt this, but the solution was posted inline in the blog entry, and I read it by accident. My window was just big enough that it was the last line displayed. =(
undefined
Something like
);f=(set
Leading to the whole line reading:
f = lambda: g();f=(set)
8 characters
the winning solutions seems to be 7 chars
0);g=(id
8 chars
f = lambda g:(0) f() <function <lambda> at 0x113478>.
f = lambda: g(""")
f()
technically not two commands, and it will look like:
>>> f = lambda: g(""")
. . . f()
undefined
undefined
undefined
LoseThos uses my own variation of C/C++.
"Yield" is the same as "Sleep(0);" in Microsoft - it voluntarily yields the CPU to the scheduler, so it can scedule the next task.
A task context can be saved and another task's context restored in half a microsecond.
while (InPort(PORT)&BUSY) Yield();
That will test a port and yield. Are you a moron or do you know what that does?
Function addresses have an "&" in front.
God is God. God says... don't_even_think_about_it Vegas face_palm genius Yawn sad shucks driving do_you_want_another I'm_in_suspense I_am_not_amused God_smack perfect spending slumin how_do_I_put_this well_obviously