Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Icon

< >

Icon is a programming language created in 1977 by Ralph Griswold.

#538on PLDB 47Years Old
Homepage · REPL · Try It Online · Wikipedia · Docs

Icon is a very high-level programming language featuring goal-directed execution and many facilities for managing strings and textual patterns. It is related to SNOBOL and SL5, string processing languages. Icon is not object-oriented, but an object-oriented extension called Idol was developed in 1996 which eventually became Unicon.. Read more on Wikipedia...


Example from Riju:
procedure main () write("Hello, world!") end
Example from hello-world:
procedure main() write("Hello World"); end
# Hello world in Icon (http://www.cs.arizona.edu/icon/) procedure main() write("Hello world") end
Example from Wikipedia:
procedure main() s := "Mon Dec 8" s ? write(Mdate() | "not a valid date") end # Define a matching function that returns # a string that matches a day month dayofmonth procedure Mdate() # Define some initial values static dates static days initial { days := ["Mon","Tue","Wed","Thr","Fri","Sat","Sun"] dates := ["Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"] } every suspend (retval <- tab(match(!days)) || # Match a day =" " || # Followed by a blank tab(match(!dates)) || # Followed by the month =" " || # Followed by a blank matchdigits(2) # Followed by at least 2 digits ) & (=" " | pos(0) ) & # Either a blank or the end of the string retval # And finally return the string end # Matching function that returns a string of n digits procedure matchdigits(n) suspend (v := tab(many(&digits)) & *v <= n) & v end

Language features

Feature Supported Example Token
Integers ✓ # \b([+-]?[0-9]+[KMGTPkmgtp]?)\b
Floats ✓ # [+-]?[0-9]*\.([0-9]*)([Ee][+-]?[0-9]*)?
Hexadecimals ✓ # \b([+-]?([2-9]|[12][0-9]|3[0-6])[rR][0-9a-zA-Z]+)\b
Strings ✓ "Hello world" "
Print() Debugging ✓ write
Comments ✓ # A comment
Line Comments ✓ # A comment #
Semantic Indentation X
View source
- Build the next great programming language · Add · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements · Part of the World Wide Scroll