|
|
|
|
|
by bjourne
4809 days ago
|
|
It takes a few hours to get used to, but once you get the hang of it it becomes an amazing language. For most things postfix notation that Factor uses reads better than applicative (prefix) notation other languages uses. It's like jQuery's or linq's method chaining, only better :) and with less syntax. For example here is the solution to problem 22 in Project Euler (http://projecteuler.net/problem=22): : names ( -- seq )
"names.txt" ascii file-contents [ quotable? ] filter "," split ;
: score ( str -- n ) [ 64 - ] map sum ;
: solution-22 ( -- n )
names natural-sort [ 1 + swap score * ] map-index sum ;
|
|