G()('al')
github.com
G()('al')
1–10 of 49 posts
Re: G()('al')
#2Re: G()('al')
#3Re: G()('al')
#4Do languages that don't use () as a function call still have to use the same syntax? Or is () just a stand-in for a function call?
Re: G()('al')
#5 > perl -e "g()()"
syntax error at -e line 1, near ")("
Execution of -e aborted due to compilation errors.Re: G()('al')
#6More generally, what properties must a programming language satisfy for this problem to be solvable in it?
My current intuition is that if a language does not denote function calls with () enclosing arguments, AND if a language does not support metaprogramming (eg. LISP macros), then the problem is not solvable in it. Still thinking about it.
Re: G()('al')
#7The 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')
#8 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.counter * 'o') + 'al'
inner.counter += 1
return inner
inner.counter = 1
return innerRe: G()('al')
#9This 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')
#10The "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.…
I'd make a solution which resets the state linked by the table though, so please submit one!