GitHunt
CO

g()()()()('al') → "gooooal"

g()('al')

g()('al') is a challenge whereby you need to write in as many languages as
possible code which enables the code g()('al') to return the string "goal",
the code g()()('al') to return the string "gooal", the code g()()()('al')
return the string "goooal", etc.

Rules

  1. You are encouraged to break the rules, cleverly.
  2. When executed, the solution must print "goal" with sufficient o's to
    demonstrate the program's functionality.
  3. The code g()('al') must appear in the source.
  4. g()('al') must not be a string literal.
  5. 'al' must be a string, or your language's equivalent thereof. You may
    use your language's standard method of creating a string (e.x. C should
    use ", ruby may use either " or ').
  6. g()('al') may not print the string. If returning a string cannot be done
    in your language, you should submit rationale as to why this is impossible
    for a solution which prints a string to be accepted.
  7. You must be able to insert an infinite number of () calls without
    modification to your solution. Therefore solutions like
    this are incorrect.
  8. g()('al') must be a valid rvalue if applicable in your language.
  9. g('al') must return "gal".
  10. If you have a solution that is close, but does not meet these rules,
    submit it anyway. A close and interesting solution is better than no
    solution.

Previous Solutions

The more exciting solutions are original, not applying techniques that have
already been discovered. The following generally applicable techniques have
already been discovered:

Languages

Solved Likely Possible Likely Impossible Impossible
C
C++
Common Lisp
Go
Haskell
Java
JavaScript
Julia
Python
R
Ruby
SH
BASH
ZSH

Help out, add some more languages!

Languages

C41.7%Python10.6%JavaScript7.4%C++7.3%Lua4.0%C#3.9%Ruby3.8%Haskell3.7%Scala3.4%Common Lisp3.3%Go2.4%Objective-J2.1%Perl1.7%Julia1.6%R1.4%Groovy1.0%Shell0.7%
Created July 27, 2014
Updated July 27, 2014
CompyENG/goal | GitHunt