]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/common/common.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / project-euler / common / common.factor
index 18ab752a0e35652a6bf6fffebd5790a4efa061cf..0ad3225e3ed056c587cc2cd79003b9b75f9ca0c1 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel make math math.functions math.matrices math.miller-rabin
     math.order math.parser math.primes.factors math.ranges math.ratios
-    sequences sorting strings unicode.case ;
+    sequences sorting strings unicode.case parser accessors vocabs.parser
+    namespaces vocabs words quotations prettyprint ;
 IN: project-euler.common
 
 ! A collection of words used by more than one Project Euler solution
@@ -130,3 +131,10 @@ PRIVATE>
 : d-transform ( triple -- new-triple )
     { { -1 -2 -2 } { 2 1 2 } { 2 2 3 } } transform ;
 
+SYNTAX: SOLUTION:
+    scan-word
+    [ name>> "-main" append create-in ] keep
+    [ drop in get vocab (>>main) ]
+    [ [ . ] swap prefix (( -- )) define-declared ]
+    2bi ;
+