This could be an interesting use case for Common Lisp reader macros.
G()('al')
11–20 of 49 posts
Re: G()('al')
#12The table at the bottom is interesting. I'd love to read articles about why it's impossible in language X. E.g. I'm familiar with C/Python and can implement a solution, and am surprised that it'd be impossible in Ruby - I don't know Ruby, and would love to know why. More generally, what properties must a programming language satisfy for this problem to be solvable in it? My current intuition is that if a language doe…
For the impossible bullets, they link to informal arguments as to why it's impossible. The ruby one has code - it's a syntax error.
Re: G()('al')
#13Re: G()('al')
#14Earlier quoted context omitted.
For the impossible bullets, they link to informal arguments as to why it's impossible. The ruby one has code - it's a syntax error.
The bullets link to non-solutions, which are not enough to formally prove that it is impossible to solve this challenge in the language.
Re: G()('al')
#15Easy in Lua. You can even write G()'al'
Re: G()('al')
#16The "complete" solutions for Python in the repo don't actually work because they don't reset the state. If you add a final line of: print g('al') for solution1 or: print m('rton') for solution2, you'll find they don't print gal/ mrton. Here's what I came up with before looking at those solutions that seems to work: def g(arg=None): if arg == 'al': return 'gal' def inner(arg=None): if arg == 'al': return 'g' + (inner.…
Resetting the state isn't one of the rules ;) I'd make a solution which resets the state linked by the table though, so please submit one!
g('al') must return "gal".
If you add assert g('al') == 'gal'
as the last line of solution 1, the assertion will not pass. I'm not saying there is a rule that mentions "resetting state". I'm saying that their failure to reset state is the bug leading to them not following the rules.Re: G()('al')
#17The table at the bottom is interesting. I'd love to read articles about why it's impossible in language X. E.g. I'm familiar with C/Python and can implement a solution, and am surprised that it'd be impossible in Ruby - I don't know Ruby, and would love to know why. More generally, what properties must a programming language satisfy for this problem to be solvable in it? My current intuition is that if a language doe…
Re: G()('al')
#18Re: G()('al')
#19This is a syntax error in perl, so impossible? > perl -e "g()()" syntax error at -e line 1, near ")(" Execution of -e aborted due to compilation errors.
Re: G()('al')
#20Earlier quoted context omitted.
Resetting the state isn't one of the rules ;) I'd make a solution which resets the state linked by the table though, so please submit one!
Rule 7 says: g('al') must return "gal". If you add assert g('al') == 'gal' as the last line of solution 1, the assertion will not pass. I'm not saying there is a rule that mentions "resetting state". I'm saying that their failure to reset state is the bug leading to them not following the rules.