diff --git a/CHANGES.txt b/CHANGES.txt index 4c3ec2caee..ef75bc65a1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -48,11 +48,17 @@ string-head head string-head? head? ?string-head ?head string-tail tail +vector-tail tail +vector-tail* tail* string-tail? tail? ?string-tail ?tail substring subseq cat2 append cat3 append3 +string/ cut +string// cut* +split1 split1 +split split Factor 0.74: ------------ diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index b1696cec16..a6d5ed4be1 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -21,7 +21,6 @@ - virtual hosts - keep alive - sleep word -- update docs - redo new compiler backend for PowerPC - plugin: supportsBackspace @@ -36,7 +35,6 @@ - faster sequence operations - generic some? all? memq? all=? - index and index* are very slow with lists -- unsafe-sbuf>string - code walker & exceptions - if two tasks write to a unix stream, the buffer can overflow - rename prettyprint to pprint diff --git a/doc/handbook.tex b/doc/handbook.tex index 54a689d365..aced70bc37 100644 --- a/doc/handbook.tex +++ b/doc/handbook.tex @@ -812,6 +812,9 @@ description=the currently executing quotation}} \glossary{ name=interpreter, description=executes quotations by iterating them and recursing into nested definitions. see compiler} +\glossary{ +name=quotation, +description=a list containing Factor code to be executed} The Factor interpreter executes quotations. Quotations are lists, and since lists can contain any Factor object, they can contain words. It is words that give quotations their operational behavior, as you can see in the following description of the interpreter algorithm. diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index cdf04d74df..b24007fd89 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -33,8 +33,8 @@ hashtables sequences ; "/library/collections/sequences-epilogue.factor" "/library/collections/hashtables.factor" "/library/collections/namespaces.factor" - "/library/collections/slicing.factor" "/library/collections/vectors-epilogue.factor" + "/library/collections/slicing.factor" "/library/collections/strings-epilogue.factor" "/library/math/matrices.factor" "/library/words.factor" diff --git a/library/collections/sbuf.factor b/library/collections/sbuf.factor index d0f2f30c31..30d998db6c 100644 --- a/library/collections/sbuf.factor +++ b/library/collections/sbuf.factor @@ -1,8 +1,12 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. +IN: kernel-internals +USING: kernel math strings ; + +: (sbuf>string) underlying dup rehash-string ; + IN: strings -USING: generic kernel kernel-internals math math-internals -sequences ; +USING: generic sequences ; M: string (grow) grow-string ; diff --git a/library/collections/sequences-epilogue.factor b/library/collections/sequences-epilogue.factor index 1c2847ca87..ea280ea40b 100644 --- a/library/collections/sequences-epilogue.factor +++ b/library/collections/sequences-epilogue.factor @@ -167,6 +167,11 @@ M: sequence = ( obj seq -- ? ) ] ifte ] ifte ; +! A repeated sequence is the same element n times. +TUPLE: repeated length object ; +M: repeated length repeated-length ; +M: repeated nth nip repeated-object ; + IN: kernel : depth ( -- n ) diff --git a/library/collections/strings-epilogue.factor b/library/collections/strings-epilogue.factor index caf3a3b019..25cc8539b9 100644 --- a/library/collections/strings-epilogue.factor +++ b/library/collections/strings-epilogue.factor @@ -16,11 +16,11 @@ sequences strings ; r> fill swap append ] ifte ; -: ch>string ( ch -- str ) 1 [ push ] keep >string ; +: ch>string ( ch -- str ) 1 [ push ] keep (sbuf>string) ; : >sbuf ( seq -- sbuf ) dup length [ swap nappend ] keep ; -M: object >string >sbuf underlying dup rehash-string ; +M: object >string >sbuf (sbuf>string) ; M: string thaw >sbuf ; M: string freeze drop >string ; diff --git a/library/math/matrices.factor b/library/math/matrices.factor index b7a2a6044d..bd2b2cba8e 100644 --- a/library/math/matrices.factor +++ b/library/math/matrices.factor @@ -12,11 +12,11 @@ vectors ; : v+ ( v v -- v ) [ + ] 2map ; : v- ( v v -- v ) [ - ] 2map ; : v* ( v v -- v ) [ * ] 2map ; +: v** ( v v -- v ) [ conjugate * ] 2map ; -! Later, this will fixed when seq-2each works properly -! : v. ( v v -- x ) 0 swap [ * + ] seq-2each ; -: +/ ( seq -- n ) 0 swap [ + ] each ; -: v. ( v v -- x ) v* +/ ; +! Later, this will fixed when 2each works properly +! : v. ( v v -- x ) 0 swap [ * + ] 2each ; +: v. ( v v -- x ) v** 0 swap [ + ] each ; ! Matrices ! The major dimension is the number of elements per row. diff --git a/library/syntax/prettyprint.factor b/library/syntax/prettyprint.factor index f5e8195bf4..f094cca2f9 100644 --- a/library/syntax/prettyprint.factor +++ b/library/syntax/prettyprint.factor @@ -163,9 +163,9 @@ M: alien prettyprint* ( alien -- str ) [ over ?prettyprint-newline matrix-rows. ] when* ; M: matrix prettyprint* ( indent obj -- indent ) - \ M[ word. >r + \ M[ word. bl >r 3 + r> row-list matrix-rows. - bl \ ]M word. prettyprint> ; + bl \ ]M word. 3 - ; : prettyprint ( obj -- ) [ diff --git a/library/test/strings.factor b/library/test/strings.factor index de4d9a4bb4..3a04d0a31d 100644 --- a/library/test/strings.factor +++ b/library/test/strings.factor @@ -13,14 +13,14 @@ USE: lists [ "abc" ] [ "ab" "c" append ] unit-test [ "abc" ] [ "a" "b" "c" append3 ] unit-test -[ 3 ] [ "a" "hola" seq-index ] unit-test -[ -1 ] [ "x" "hola" seq-index ] unit-test -[ 0 ] [ "" "a" seq-index ] unit-test -[ 0 ] [ "" "" seq-index ] unit-test -[ 0 ] [ "hola" "hola" seq-index ] unit-test -[ 1 ] [ "ol" "hola" seq-index ] unit-test -[ -1 ] [ "amigo" "hola" seq-index ] unit-test -[ -1 ] [ "holaa" "hola" seq-index ] unit-test +[ 3 ] [ "a" "hola" start ] unit-test +[ -1 ] [ "x" "hola" start ] unit-test +[ 0 ] [ "" "a" start ] unit-test +[ 0 ] [ "" "" start ] unit-test +[ 0 ] [ "hola" "hola" start ] unit-test +[ 1 ] [ "ol" "hola" start ] unit-test +[ -1 ] [ "amigo" "hola" start ] unit-test +[ -1 ] [ "holaa" "hola" start ] unit-test [ "Beginning" ] [ 9 "Beginning and end" head ] unit-test @@ -76,7 +76,7 @@ unit-test [ f ] [ [ 0 10 "hello" subseq ] [ not ] catch ] unit-test -[ [ "hell" "o wo" "rld" ] ] [ 4 "hello world" split-n ] unit-test +[ [ "hell" "o wo" "rld" ] ] [ 4 "hello world" groups ] unit-test [ 4 ] [ 0 "There are Four Upper Case characters" diff --git a/library/tools/debugger.factor b/library/tools/debugger.factor index 1d08df5bac..9174b933a9 100644 --- a/library/tools/debugger.factor +++ b/library/tools/debugger.factor @@ -73,15 +73,14 @@ M: no-method error. ( error -- ) ] make-string print ; : parse-dump ( error -- ) - [ - "Parsing " % - dup parse-error-file [ "" ] unless* % ":" % - dup parse-error-line [ 1 ] unless* unparse , - ] make-string print + "Parsing " write + dup parse-error-file [ "" ] unless* write + ":" write + dup parse-error-line [ 1 ] unless* unparse print dup parse-error-text dup string? [ print ] [ drop ] ifte - [ parse-error-col CHAR: \s fill % "^" % ] make-string print ; + parse-error-col CHAR: \s fill write "^" print ; M: parse-error error. ( error -- ) dup parse-dump delegate error. ;