From: Daniel Ehrenberg Date: Wed, 19 Dec 2007 17:40:55 +0000 (-0500) Subject: Merge branch 'master' into xml X-Git-Tag: 0.94~2763^2~127^2~45 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=b8f210a3be503acac747b799341e6bbb163a3dfb Merge branch 'master' into xml Conflicts: extra/rss/rss.factor extra/sequences/lib/lib.factor extra/xml/data/data.factor --- b8f210a3be503acac747b799341e6bbb163a3dfb diff --cc extra/rss/rss.factor index d34a985518,cfb1c903e8..233dfcb221 --- a/extra/rss/rss.factor +++ b/extra/rss/rss.factor @@@ -81,22 -85,26 +85,22 @@@ C: entr ] if ; ! Atom generation -: simple-tag, ( content name -- ) - [ , ] tag, ; - -: simple-tag*, ( content name attrs -- ) - [ , ] tag*, ; - : entry, ( entry -- ) - "entry" [ - dup entry-title "title" { { "type" "html" } } simple-tag*, - "link" over entry-link "href" associate contained*, - dup entry-pub-date "published" simple-tag, - entry-description [ "content" { { "type" "html" } } simple-tag*, ] when* - ] tag, ; + << entry >> [ + << title >> [ dup entry-title , ] + << link [ dup entry-link ] == href // >> + << published >> [ dup entry-pub-date , ] + << content >> [ entry-description , ] + ] ; : feed>xml ( feed -- xml ) - "feed" { { "xmlns" "http://www.w3.org/2005/Atom" } } [ - dup feed-title "title" simple-tag, - "link" over feed-link "href" associate contained*, - feed-entries [ entry, ] each - ] make-xml* ; + > [ + << title >> [ dup feed-title , ] + << link [ dup feed-link ] == href // >> + feed-entries [ entry, ] each + ] + XML> ; - : write-feed ( feed -- xml ) + : write-feed ( feed -- ) feed>xml write-xml ; diff --cc extra/sequences/lib/lib.factor index 2f98e27467,ba2fb055e2..ea6fdd141b --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@@ -63,6 -64,61 +64,65 @@@ IN: sequences.li : delete-random ( seq -- value ) [ length random ] keep [ nth ] 2keep delete-nth ; +: split-around ( seq quot -- before elem after ) + dupd find over [ "Element not found" throw ] unless + >r cut-slice 1 tail r> swap ; inline ++ + : (map-until) ( quot pred -- quot ) + [ dup ] swap 3compose + [ [ drop t ] [ , f ] if ] compose [ find 2drop ] curry ; + + : map-until ( seq quot pred -- newseq ) + (map-until) { } make ; + + : take-while ( seq quot -- newseq ) + [ not ] compose + [ find drop [ head-slice ] when* ] curry + [ dup ] swap compose keep like ; + + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + + + : exact-strings ( alphabet length -- seqs ) + >r dup length r> exact-number-strings map-alphabet ; + + : strings ( alphabet length -- seqs ) + >r dup length r> number-strings map-alphabet ; + + : nths ( nths seq -- subseq ) + ! nths is a sequence of ones and zeroes + >r [ length ] keep [ nth 1 = ] curry subset r> + [ nth ] curry { } map-as ; + + : power-set ( seq -- subsets ) + 2 over length exact-number-strings swap [ nths ] curry map ; + + : cut-find ( seq pred -- before after ) + dupd find drop dup [ cut ] when ; + + : cut3 ( seq pred -- first mid last ) + [ cut-find ] keep [ not ] compose cut-find ; + + : (cut-all) ( seq pred quot -- ) + [ >r cut3 r> dip >r >r , r> [ , ] when* r> ] 2keep + pick [ (cut-all) ] [ 3drop ] if ; + + : cut-all ( seq pred quot -- first mid last ) + [ (cut-all) ] { } make ; + + : human-sort ( seq -- newseq ) + [ dup [ digit? ] [ string>number ] cut-all ] { } map>assoc + sort-values keys ; diff --cc extra/xml/data/data.factor index cb7dd3c703,725d6da3cc..77f7c4d929 --- a/extra/xml/data/data.factor +++ b/extra/xml/data/data.factor @@@ -1,6 -1,6 +1,6 @@@ ! Copyright (C) 2005, 2006 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. - USING: kernel sequences sequences.private assocs arrays delegate ; -USING: kernel sequences sequences.private assocs arrays vectors ; ++USING: kernel sequences sequences.private assocs arrays delegate vectors ; IN: xml.data TUPLE: name space tag url ;