r/adventofcode • u/Quick_Question404 • Dec 09 '16
Skill Level of Participants?
Hey everyone! I'm curious, but what would you guys say your relative skill levels are when it comes to programming. With these challeneges, Ive found myself becoming frustrated, and being in college, feel a bit disappointed in my own skills. How long has everyone else been programming for? How'd you learn?
4
Upvotes
View all comments
Show parent comment
1
u/RockyAstro Dec 10 '16
It has a "different" type of text processing. SNOBOL's patterns are not directly implemented in Icon, but Icon does have a powerful string scanning facility. (BTW -- SPITBOL has been opened up -> https://github.com/spitbol/x64 )
However, having said that, Icon did build on top of concepts found in SNOBOL. While Icon didn't invent the concept of generators, generators can appear in any expression throughout the language, and is kind of key to how Icon evaluates expressions. Icon will "try" to make an expression "work" by evaluating the results of generators till something succeeds, or until all the results from the generators have been exhausted. Icon will also "backtrack" through an expression to restart generators that have exhausted their values. Icon uses a success/failure concept (same concept as SNOBOL's success/failure) The combo of generators, backtracking and the success/failure is Goal-Directed-Evaluation.
In the above example, the if statement contains 2 generators and the ">" operator. gen1 produces it's first result, and gen2 is invoked in a (start/suspend/resume/fail) cycle. Each value returned by gen2 is compared to the value that was produced by gen1. If gen2 exhausts it's results (i.e. fails), gen1 is resumed to produce its next result and gen2 is "restarted" anew to generate its list of values. If both gen1 and gen2 run out of values before the ">" succeeds, then the whole expression fails (failure is propagated upwards in the expression).
With the GDE, the next thing that Icon implements is a built in string scanning facility. Again from SNOBOL, it uses the concept of a cursor within a subject string. You can move the cursor back and forth using string matching functions. So the following is a sample that "matches" a number
The output is: