Live data from Hacker News

G()('al')

github.com

11–20 of 49 posts

Re: G()('al')

#12
post #6

The 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.

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

#14
post #12

Earlier 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.

Agreed. These are informal. If you want to make a formal proof that it's impossible, I'll make a new category.

Re: G()('al')

#16

The "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!

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.

Re: G()('al')

#17
post #6

The 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…

Ruby and Java both lack first class functions--functions can't return values that can be directly called with () (unless this has changed with Java 8?).

Re: G()('al')

#19
post #5

This 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.

Nah, you can use a source filter. "man perlfilter"

Re: G()('al')

#20

Earlier 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.

Thanks for pointing this out, it's now fixed.

https://github.com/eatnumber1/goal/pull/18

Post reply on HN