* 'master' of git://factorcode.org/git/factor: (23 commits)
only use -fPIC on the ffi library
fix load errors, help lint
add using
build with -fPIC on linux64
update code for usages of add-library
move a lot of words to alien.libraries
Slides from talk at PyCon VM summit, Chicago 2009
Fix hang when running ui tests
Fix compiler.tree.debugger tests
Merge tools.test.ui into ui.gadgets.debug
compile an ffi test library, reduce factor runtime by 6kb!
make add-library normalize-path, use libfactor-ffi-tests for testing ffi
add sms, twitter fields to account. create sitewatcher account when user registers
Better error message if user forgets with-ui
Fix hello-unicode for deployment
remove loading freetype library on CE
remove dead freetype code from Makefile
A+b now focuses the search field
Fix bitrot in compiler.tree.debugger
- definitions.icons now has a reference article
...
[ 233168 ] [ euler001 ] unit-test
[ 233168 ] [ euler001a ] unit-test
[ 233168 ] [ euler001b ] unit-test
+[ 233168 ] [ euler001c ] unit-test
-! Copyright (c) 2007 Aaron Schaefer.
+! Copyright (c) 2007, 2008 Aaron Schaefer, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.ranges sequences project-euler.common ;
IN: project-euler.001
! [ euler001b ] 100 ave-time
! 0 ms run / 0 ms GC ave time - 100 trials
+
+: euler001c ( -- answer )
+ 1000 [ { 3 5 } [ mod 0 = ] with contains? ] filter sum ;
+
+! [ euler001c ] 100 ave-time
+! 0 ms ave run time - 0.06 SD (100 trials)
+
SOLUTION: euler001
10 99 [a,b] dup cartesian-product [ first2 < ] filter ;
: safe? ( ax xb -- ? )
- [ 10 /mod ] bi@ -roll = rot zero? not and nip ;
+ [ 10 /mod ] bi@ [ = ] dip zero? not and nip ;
: ax/xb ( ax xb -- z/f )
2dup safe? [ [ 10 /mod ] bi@ 2nip / ] [ 2drop f ] if ;
>lower [ CHAR: a - 1+ ] sigma ;
: cartesian-product ( seq1 seq2 -- seq1xseq2 )
- swap [ swap [ 2array ] with map ] with map concat ;
+ [ [ 2array ] with map ] curry map concat ;
: log10 ( m -- n )
log 10 log / ;
: number>digits ( n -- seq )
[ dup 0 = not ] [ 10 /mod ] produce reverse nip ;
+: number-length ( n -- m )
+ log10 floor 1+ >integer ;
+
: nth-triangle ( n -- n )
dup 1+ * 2 / ;