]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorAaron Schaefer <aaron@elasticdog.com>
Tue, 24 Mar 2009 06:41:53 +0000 (02:41 -0400)
committerAaron Schaefer <aaron@elasticdog.com>
Tue, 24 Mar 2009 06:41:53 +0000 (02:41 -0400)
* 'master' of git://factorcode.org/git/factor: (113 commits)
  Round mouse co-ordinates
  Fix bunny deployment
  Fix site-watcher tests
  make multimethods tests pass
  make ecdsa unportable for now
  check pango-1.0
  cocoa.messages: cleanup
  Move synopsis* from definitions to see
  Faster PEG compile times; inline less, use execute( instead
  delete factor/ every time after a build is finished.  you can easily check it out by knowing the git-id
  Condomization wraps lambdas in condoms to protect them from macro-transmitted diseases. cond, case and other macros work better now if lambdas appear where quotations are expected
  Fixing compile errors, test failures and help lint failures
  Add a missing step to the tutorial.
  Add stack declarations to primitives during bootstrap now that ( is just a comment and won't affect HELP: anymore
  OpenSSL checksum => native implementation
  kernel doesn't need to depend on classes.tuple.private
  Remove useless declarations
  Fixing unit tests for syntax change
  tools.disassembler now uses udis on Windows
  Add promises unit tests
  ...

Conflicts:
extra/project-euler/001/001.factor

1  2 
extra/project-euler/001/001.factor
extra/project-euler/033/033.factor
extra/project-euler/common/common.factor

index c9145c9b73368eb0b8fb3ee5635ef282e4f85b48,de4345db689e8f3dfc5b5b395c007a46c20f5042..17f8d0386d80dbbb591530f0892f041ae7eb709f
@@@ -1,6 -1,6 +1,6 @@@
 -! 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 ;
+ USING: kernel math math.ranges sequences project-euler.common ;
  IN: project-euler.001
  
  ! http://projecteuler.net/index.php?section=problems&id=1
@@@ -51,11 -51,4 +51,11 @@@ PRIVATE
  ! [ euler001b ] 100 ave-time
  ! 0 ms run / 0 ms GC ave time - 100 trials
  
- MAIN: euler001
 +
 +: 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
index 2cc114a545424f22a76f2fcb603b8466020eb7fe,c7c3fea5da7d52e6e100776d2f03e131e1202e98..780015ab77b8b6e90a96559036c2d69b0c4a20f8
@@@ -33,7 -33,7 +33,7 @@@ IN: project-euler.03
      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 ;
@@@ -52,4 -52,4 +52,4 @@@ PRIVATE
  ! [ euler033 ] 100 ave-time
  ! 7 ms ave run time - 1.31 SD (100 trials)
  
MAIN: euler033
SOLUTION: euler033
index 18ab752a0e35652a6bf6fffebd5790a4efa061cf,423512465eda8cf7d1d0fa312411c046f6c8db84..0ad3225e3ed056c587cc2cd79003b9b75f9ca0c1
@@@ -2,7 -2,8 +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
@@@ -56,7 -57,7 +57,7 @@@ PRIVATE
      >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 / ;
@@@ -74,9 -75,6 +75,9 @@@
  : 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 / ;
  
  : 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 ;