"bootstrap." prepend require ;
: load-components ( -- )
- "include" "exclude" [ get-global " " split harvest ] bi@ diff
+ "include" "exclude" [ get-global words harvest ] bi@ diff
[ load-component ] each ;
: print-time ( us -- )
[ number>string ] [ month-name ] bi* swap " " glue 20 center. ;
: days-header. ( -- )
- day-abbreviations2 " " join print ;
+ day-abbreviations2 unwords print ;
: days. ( year month -- )
[ 1 (day-of-week) dup [ " " write ] times ]
[ first [ /mod ] [ dup ] if* ] [ second ] bi swap
dup 0 > [ number>string prepend , ] [ 2drop ] if
] each drop
- ] { } make [ "0s" ] [ reverse " " join ] if-empty ;
+ ] { } make [ "0s" ] [ reverse unwords ] if-empty ;
M: real elapsed-time
>integer elapsed-time ;
! Copyright (C) 2008, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes.tuple compiler.cfg
-compiler.cfg.builder compiler.cfg.finalization compiler.cfg.gc-checks
-compiler.cfg.instructions compiler.cfg.linearization
-compiler.cfg.optimizer compiler.cfg.registers
-compiler.cfg.representations compiler.cfg.save-contexts
-compiler.cfg.utilities compiler.tree.builder compiler.tree.optimizer
-formatting fry io kernel math namespaces prettyprint quotations
-sequences strings words ;
+compiler.cfg.builder compiler.cfg.finalization
+compiler.cfg.gc-checks compiler.cfg.instructions
+compiler.cfg.linearization compiler.cfg.optimizer
+compiler.cfg.registers compiler.cfg.representations
+compiler.cfg.save-contexts compiler.cfg.utilities
+compiler.tree.builder compiler.tree.optimizer formatting io
+kernel math namespaces prettyprint quotations sequences
+splitting strings words ;
IN: compiler.cfg.debugger
GENERIC: test-builder ( quot -- cfgs )
M: insn insn. ( insn -- )
tuple>array unclip-last insn-number. [
dup string? [ ] [ unparse ] if
- ] map " " join write nl ;
+ ] map unwords write nl ;
: block-header. ( bb -- )
[ number>> ] [ kill-block?>> "(k)" "" ? ] bi
<<
STRING: parse-insn-slot-specs-code
USING: compiler.cfg.instructions.syntax prettyprint splitting ;
-"use: src/int-rep temp: temp/int-rep" " " split parse-insn-slot-specs .
+"use: src/int-rep temp: temp/int-rep" words parse-insn-slot-specs .
;
STRING: parse-insn-slot-specs-result
: (postgresql-error-message) ( handle -- str )
PQerrorMessage
- "\n" split [ [ blank? ] trim ] map "\n" join ;
+ "\n" split [ [ blank? ] trim ] map unlines ;
: postgresql-error-message ( -- str )
db-connection get handle>> (postgresql-error-message) ;
IN: db.sqlite.tests
: normalize ( str -- str' )
- " \n" split harvest " " join ;
+ " \n" split harvest unwords ;
! delete-trigger-restrict
${
:: doc-range ( from to document -- string )
from to [ [ from to ] dip document (doc-range) ] map-lines
- "\n" join ;
+ unlines ;
: add-undo ( edit document -- )
dup inside-undo?>> [ 2drop ] [
[ cut-slice ] [ f ] if* swap ;
:: (take-until) ( state delimiter accum -- string/f state' )
- state empty? [ accum "\n" join f ] [
+ state empty? [ accum unlines f ] [
state unclip-slice :> ( rest first )
first delimiter split1 :> ( before after )
before accum push
[ >time ]
[ year>> number>string ]
} cleave
- ] output>array " " join ; inline
+ ] output>array unwords ; inline
: week-of-year ( timestamp day -- n )
[ dup clone 1 >>month 1 >>day day-of-week dup ] dip > [ 7 swap - ] when
: parse-list ( ftp-response -- ftp-response )
dup strings>>
- [ " " split harvest ] map
+ [ words harvest ] map
dup length {
{ 11 [ parse-list-11 ] }
{ 9 [ parse-list-11 ] }
: validation-failed ( -- * )
post-request? revalidate-url and [
begin-conversation
- nested-forms-key param " " split harvest nested-forms cset
+ nested-forms-key param words harvest nested-forms cset
form get form cset
<continue-conversation>
] [ <400> ] if*
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
: hidden-nested-fields ( -- xml )
- nested-forms get " " join f like nested-forms-key
+ nested-forms get unwords f like nested-forms-key
hidden-form-field ;
: render-hidden ( for -- xml )
M: gir-not-found summary
[ name>> "“" "” file not found on paths:\n" surround ]
- [ paths>> "\n" join ] bi
+ [ paths>> unlines ] bi
"\n\nUse the existing path or declare GIR_DIRS environment variable"
3append ;
: css-classes ( classes -- stylesheet )
[
[ css-style " { " "}" surround ] [ "." prepend ] bi* prepend
- ] { } assoc>map "\n" join ;
+ ] { } assoc>map unlines ;
:: css-styles-to-classes ( body -- stylesheet body )
H{ } clone :> classes
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators compiler.units
-definitions.icons effects fry hashtables help.stylesheet
-help.topics io io.styles kernel locals make math namespaces
-present prettyprint prettyprint.stylesheet quotations see
-sequences sequences.private sets sorting strings urls vocabs
+definitions.icons effects hashtables help.stylesheet help.topics
+io io.styles kernel make math namespaces present prettyprint
+prettyprint.stylesheet quotations see sequences
+sequences.private sets sorting splitting strings urls vocabs
words words.symbol ;
FROM: prettyprint.sections => with-pprint ;
IN: help.markup
] ($block) ; inline
: $code ( element -- )
- "\n" join dup <input> [ write ] ($code) ;
+ unlines dup <input> [ write ] ($code) ;
: $syntax ( element -- ) "Syntax" $heading $code ;
"Examples" $heading print-element ;
: $example ( element -- )
- unclip-last [ "\n" join ] dip over <input> [
+ unclip-last [ unlines ] dip over <input> [
[ print ] [ output-style get format ] bi*
] ($code) ;
{ \ $vocab-link [ second ] }
{ \ $emphasis [ second ] }
{ \ $subsection [ second article-name ] }
- { \ $subsections [ rest [ article-name ] map " " join ] }
- { \ $description [ rest [ element-value ] map " " join ] }
- { \ $notes [ rest [ element-value ] map " " join ] }
- { \ $snippet [ rest [ element-value ] map " " join ] }
+ { \ $subsections [ rest [ article-name ] map unwords ] }
+ { \ $description [ rest [ element-value ] map unwords ] }
+ { \ $notes [ rest [ element-value ] map unwords ] }
+ { \ $snippet [ rest [ element-value ] map unwords ] }
[ 2drop f ]
} case
] [ dup string? [ drop f ] unless ] if ;
MEMO: article-words ( name -- words )
- article-content [ element-value ] map " " join search-words
+ article-content [ element-value ] map unwords search-words
[ [ digit? ] all? ] reject
[ [ { [ letter? ] [ digit? ] } 1|| not ] trim ] map! harvest ;
USING: accessors arrays assocs classes classes.builtin
classes.intersection classes.mixin classes.predicate
classes.singleton classes.tuple classes.union combinators
-effects fry generic help help.markup help.stylesheet
-help.topics io io.pathnames io.styles kernel macros make
-namespaces sequences sorting summary vocabs vocabs.files
-vocabs.hierarchy vocabs.loader vocabs.metadata words
-words.symbol ;
+effects generic help help.markup help.stylesheet help.topics io
+io.pathnames io.styles kernel macros make namespaces sequences
+sorting splitting summary vocabs vocabs.files vocabs.hierarchy
+vocabs.loader vocabs.metadata words words.symbol ;
IN: help.vocabs
: about ( vocab -- )
[
[ <$pretty-link> ]
[ superclass-of <$pretty-link> ]
- [ "slots" word-prop [ name>> ] map " " join <$snippet> ]
+ [ "slots" word-prop [ name>> ] map unwords <$snippet> ]
tri 3array
] map
{ { $strong "Class" } { $strong "Superclass" } { $strong "Slots" } } prefix
"content-type: text/html; charset=UTF-8"
"date: Wed, 12 Oct 2011 18:57:49 GMT"
"server: Factor http.server"
- } [ "\n" join ] [ "\r\n" join ] bi
+ } [ unlines ] [ "\r\n" join ] bi
[ [ read-response ] with-string-reader ] same?
] unit-test
swap >>content-type ;
: parse-content-type-attributes ( string -- attributes )
- " " split harvest [
+ words harvest [
"=" split1
"\"" ?head drop "\"" ?tail drop
] { } map>assoc ;
"connection: close"
"host: 127.0.0.1:55532"
"user-agent: Factor http.client"
- } [ "\n" join ] [ "\r\n" join ] bi
+ } [ unlines ] [ "\r\n" join ] bi
[ string>request ] same?
] unit-test
"connection: close"
"host: 127.0.0.1:55532"
"user-agent: Factor http.client"
- } [ "\n" join ] [ "\r\n" join ] bi
+ } [ unlines ] [ "\r\n" join ] bi
[ [ read-request ] with-string-reader ] same?
] unit-test
TUPLE: range ufirst ulast bfirst blast ;
: b>byte-array ( string -- byte-array )
- " " split [ hex> ] B{ } map-as ;
+ words [ hex> ] B{ } map-as ;
: add-range ( contained ranges -- )
[
<PRIVATE
: parse-iana ( file -- synonym-set )
utf8 file-lines { "" } split [
- [ " " split ] map
+ [ words ] map
[ first { "Name:" "Alias:" } member? ] filter
values { "None" } diff
] map harvest ;
] when ;
: join-arguments ( args -- cmd-line )
- [ escape-argument ] map " " join ;
+ [ escape-argument ] map unwords ;
: lookup-priority ( process -- n )
priority>> {
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences namespaces words assocs logging sorting
-prettyprint io io.styles io.files io.encodings.utf8
-strings combinators accessors arrays math
-logging.server logging.parser calendar.format ;
+USING: accessors arrays assocs io io.styles kernel logging
+logging.parser math namespaces prettyprint sequences sorting
+splitting ;
IN: logging.analysis
SYMBOL: word-names
[
[ first name>> write bl ]
[ second write ": " write ]
- [ third "\n" join write ]
+ [ third unlines write ]
tri
] histogram.
nl nl
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs calendar calendar.format calendar.parser
combinators io io.encodings.utf8 io.files kernel logging
-logging.server make namespaces peg peg.parsers prettyprint sequences
-strings vectors words ;
+logging.server make namespaces peg peg.parsers prettyprint
+sequences splitting strings vectors words ;
IN: logging.parser
TUPLE: log-entry date level word-name message ;
[ date>> log-timestamp. bl ]
[ level>> pprint bl ]
[ word-name>> write nl ]
- [ message>> "\n" join print ]
+ [ message>> unlines print ]
} cleave ;
: log-entries. ( errors -- )
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs combinators command-line io kernel make
math math.functions math.parser math.primes math.ranges
-namespaces sequences sequences.product sorting ;
+namespaces sequences sequences.product sorting splitting ;
IN: math.primes.factors
<PRIVATE
: unix-factor ( string -- )
dup string>number [
[ ": " append write ]
- [ factors [ number>string ] map " " join print ] bi*
+ [ factors [ number>string ] map unwords print ] bi*
] [
"factor: `" "' is not a valid positive integer" surround print
] if* flush ;
over string? [ member? ] [ [ member? ] curry any? ] if ;
: gl-extensions ( -- seq )
- GL_EXTENSIONS glGetString " " split ;
+ GL_EXTENSIONS glGetString words ;
: has-gl-extensions? ( extensions -- ? )
gl-extensions [ (has-extension?) ] curry all? ;
: (make-gl-extensions-error) ( required-extensions -- )
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types effects io.pathnames kernel math
-math.parser quotations sequences strings vocabs words ;
+math.parser quotations sequences splitting strings vocabs words ;
IN: present
GENERIC: present ( object -- string )
M: callable present
[ "[ ]" ] [
[ drop "[ " ]
- [ [ present ] map " " join ]
+ [ [ present ] map unwords ]
[ drop " ]" ] tri 3append
] if-empty ;
[ [ lines ] map format-row flip ] map concat flip
[ { } ] [
[ but-last-slice [ format-column ] map! drop ] keep
- flip [ " " join ] map!
+ flip [ unwords ] map!
] if-empty ;
[
"-staging" , "-no-user-init" , "-pic=0" ,
[ staging-image-name "-output-image=" prepend , ]
- [ " " join "-include=" prepend , ] bi
+ [ unwords "-include=" prepend , ] bi
] [
input-image-name "-i=" prepend ,
"-resource-path=" "" resource-path append ,
dup year>> dup now year>> =
[ drop listing-time ] [ nip number>string ] if
5 CHAR: \s pad-head
- ] tri 3array " " join ;
+ ] tri 3array unwords ;
: read>string ( ? -- string ) "r" "-" ? ; inline
[ kinfo_proc memory>struct ] map ;
: ps-arg ( kp_proc -- arg )
- [ p_pid>> args rest " " join ] [
+ [ p_pid>> args rest unwords ] [
drop p_comm>> 0 over index [ head ] when* >string
] recover ;
SYMBOL: nested-examples
: example-using ( using -- )
- " " join "example-using" [
+ unwords "example-using" [
nested-examples get 4 0 ? CHAR: \s <string> "example-indent" [
"${example-indent}\"Example:\"
${example-indent}{ $example \"USING: ${example-using} ;\"
"\n" split
[ rest-slice [ [ blank? ] trim-head-slice ] map! drop ]
[ but-last-slice [ [ blank? ] trim-tail-slice ] map! drop ]
- [ " " join ]
+ [ unwords ]
tri ;
: last-line? ( document line -- ? )
SLOT: string
M: label string>>
- text>> dup string? [ "\n" join ] unless ; inline
+ text>> dup string? [ unlines ] unless ; inline
<PRIVATE
{ presented image-style } pick '[ _ key? ] any? [
pane-text
] [
- [ " " split ] 2dip
+ [ words ] 2dip
[ pane-bl ] [ pane-text ] bi-curry bi-curry
interleave
] if ;
M: f draw-cell 2drop ;
: single-line ( str -- str' )
- dup [ "\r\n" member? ] any? [ lines " " join ] when ;
+ dup [ "\r\n" member? ] any? [ lines unwords ] when ;
M: string cell-dim single-line text-dim first2 ceiling 0 ;
M: string draw-cell single-line draw-text ;
documents.elements fonts hashtables help help.markup help.tips
io io.styles kernel lexer listener literals math math.vectors
models models.arrow models.delay namespaces parser prettyprint
-sequences source-files.errors strings system threads ui
-ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
+sequences source-files.errors splitting strings system threads
+ui ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.status-bar ui.gadgets.toolbar ui.gadgets.tracks
ui.gestures ui.operations ui.pens.solid ui.theme
M:: interactor stream-read-unsafe ( n buf interactor -- count )
n [ 0 ] [
drop
- interactor interactor-read dup [ "\n" join ] when
+ interactor interactor-read dup [ unlines ] when
n short [ head-slice 0 buf copy ] keep
] if-zero ;
M: interactor stream-read-until
swap '[
_ interactor-read [
- "\n" join CHAR: \n suffix
+ unlines CHAR: \n suffix
[ _ member? ] dupd find
[ [ head ] when* ] dip dup not
] [ f f f ] if*
: parse-collation-test-shifted ( -- lines )
collation-test-lines
- [ ";" split first " " split [ hex> ] "" map-as ] map ;
+ [ ";" split first words [ hex> ] "" map-as ] map ;
: tail-from-last ( string char -- string' )
'[ _ = ] dupd find-last drop 1 + tail ; inline
: line>test-weights ( string -- pair )
";" split1 [
- " " split [ hex> ] map
+ words [ hex> ] map
] [
"#" split1 nip CHAR: [ tail-from-last
"]" split1 drop
"|" split 4 head
- [ " " split harvest [ hex> ] map ] map
+ [ words harvest [ hex> ] map ] map
] bi* 2array ;
! These tests actually would pass if I didn't fix up
] map ;
: parse-keys ( string -- chars )
- " " split [ hex> ] "" map-as ;
+ words [ hex> ] "" map-as ;
: parse-ducet ( file -- ducet )
load-data-file [ [ parse-keys ] [ parse-weight ] bi* ] H{ } assoc-map-as ;
: (process-decomposed) ( data -- alist )
5 swap (process-data)
- [ " " split [ hex> ] map ] assoc-map ;
+ [ words [ hex> ] map ] assoc-map ;
: exclusions-file ( -- filename )
"vocab:unicode/UCD/CompositionExclusions.txt" ;
] H{ } assoc-map-as ;
: multihex ( hexstring -- string )
- " " split [ hex> ] map sift ;
+ words [ hex> ] map sift ;
PRIVATE>
values [
[
"#@" split first [ CHAR: \s = ] trim-tail ";" split harvest
- [ " " split [ hex> ] "" map-as ] map
+ [ words [ hex> ] "" map-as ] map
] map
] map concat ;
[ CHAR: \t = ] trim-tail [ [ CHAR: \s = ] trim ] bi@
{
{ "address sizes" [
- "," split [ [ CHAR: \s = ] trim " " split first string>number ] map
+ "," split [ [ CHAR: \s = ] trim words first string>number ] map
>>address-sizes
] }
{ "apicid" [ string>number >>apicid ] }
{ "bogomips" [ string>number >>bogomips ] }
{ "cache size" [
- " " split first [ CHAR: \s = ] trim
+ words first [ CHAR: \s = ] trim
string>number 1024 * >>cache-size
] }
{ "cache_alignment" [ string>number >>cache-alignment ] }
{ "cpuid level" [ string>number >>cpuid-level ] }
{ "f00f_bug" [ "yes" = >>f00f-bug? ] }
{ "fdiv_bug" [ "yes" = >>fdiv-bug? ] }
- { "flags" [ " " split harvest >>flags ] }
+ { "flags" [ words harvest >>flags ] }
{ "fpu" [ "yes" = >>fpu? ] }
{ "fpu_exception" [ "yes" = >>fpu-exception? ] }
{ "hlt_bug" [ "yes" = >>hlt-bug? ] }
: parse-proc-loadavg ( -- obj )
"/proc/loadavg" utf8 file-lines first
- " " split [
+ words [
{
[ string>number ]
[ string>number ]
! Different kernels have fewer fields. Make sure we have enough.
: parse-proc-meminfo ( -- meminfo )
"/proc/meminfo" utf8 file-lines
- [ " " split harvest second string>number 1024 * ] map
+ [ words harvest second string>number 1024 * ] map
proc-meminfo "slots" word-prop length f pad-tail
[ proc-meminfo boa ] input<sequence ;
[ second [ line>cpu ] map ]
[
third
- [ " " split1 nip " " split [ string>number ] map ] map
+ [ " " split1 nip words [ string>number ] map ] map
[
{
[ ]
: parse-proc-uptime ( -- uptime )
"/proc/uptime" utf8 file-lines first
- " " split first2 [ string>number seconds ] bi@
+ words first2 [ string>number seconds ] bi@
proc-uptime boa ;
! /proc/pid/*
: parse-proc-pid-stat ( pid -- stat )
"stat" proc-pid-path
proc-first-line
- " " split harvest
+ words harvest
pid-stat "slots" word-prop length "0" pad-tail
[ dup string>number [ nip ] when* ] map
[ pid-stat boa ] input<sequence ;
"wglGetExtensionsStringARB" wglGetProcAddress >boolean ;
: wgl-extensions ( hdc -- extensions )
- has-wglGetExtensionsStringARB? [ wglGetExtensionsStringARB " " split ] [ drop { } ] if ;
+ has-wglGetExtensionsStringARB? [ wglGetExtensionsStringARB words ] [ drop { } ] if ;
: has-wgl-extensions? ( hdc extensions -- ? )
swap wgl-extensions [ member? ] curry all? ;
lines [ split-line ] map! ;
: join-elements ( wrapped-lines -- lines )
- [ " " join ] map! ;
+ [ unwords ] map! ;
: join-lines ( strings -- string )
- "\n" join ;
+ unlines ;
PRIVATE>
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes classes.algebra
classes.algebra.private classes.builtin classes.private
-combinators kernel make sequences words ;
+combinators kernel make sequences splitting words ;
IN: classes.intersection
PREDICATE: intersection-class < class
] if-empty ;
M: anonymous-intersection class-name
- participants>> [ class-name ] map " " join ;
+ participants>> [ class-name ] map unwords ;
PRIVATE>
"INSTANCE: sequence mixin-forget-test"
"GENERIC: mixin-forget-test-g ( x -- y )"
"M: mixin-forget-test mixin-forget-test-g ;"
- } "\n" join <string-reader> "mixin-forget-test"
+ } unlines <string-reader> "mixin-forget-test"
parse-stream drop
] unit-test
"INSTANCE: hashtable mixin-forget-test"
"GENERIC: mixin-forget-test-g ( x -- y )"
"M: mixin-forget-test mixin-forget-test-g ;"
- } "\n" join <string-reader> "mixin-forget-test"
+ } unlines <string-reader> "mixin-forget-test"
parse-stream drop
] unit-test
" f"
" 3"
"}"
- } "\n" join eval( -- tuple )
+ } unlines eval( -- tuple )
] unit-test
{ T{ parsing-corner-case f 3 } } [
"T{ parsing-corner-case"
" { x 3 }"
"}"
- } "\n" join eval( -- tuple )
+ } unlines eval( -- tuple )
] unit-test
{ T{ parsing-corner-case f 3 } } [
"T{ parsing-corner-case {"
" x 3 }"
"}"
- } "\n" join eval( -- tuple )
+ } unlines eval( -- tuple )
] unit-test
{
"USE: classes.tuple.parser.tests T{ parsing-corner-case"
" { x 3 }"
- } "\n" join eval( -- tuple )
+ } unlines eval( -- tuple )
] [ error>> unexpected-eof? ] must-fail-with
[
{
"USE: classes.tuple.parser.tests T{ parsing-corner-case {"
" x 3 }"
- } "\n" join eval( -- tuple )
+ } unlines eval( -- tuple )
] [ error>> unexpected-eof? ] must-fail-with
TUPLE: bad-inheritance-tuple ;
classes.algebra.private classes.builtin classes.private
classes.tuple classes.tuple.private combinators definitions
kernel kernel.private math math.private quotations sequences
-slots.private sorting words ;
+slots.private sorting splitting words ;
IN: classes.union
PREDICATE: union-class < class
members>> [ instance? ] with any? ;
M: anonymous-union class-name
- members>> [ class-name ] map " " join ;
+ members>> [ class-name ] map unwords ;
M: union-class normalize-class
class-members <anonymous-union> normalize-class ;
"GENERIC: change-combination ( obj a -- b )"
"M: integer change-combination 2drop 1 ;"
"M: array change-combination 2drop 2 ;"
- } "\n" join <string-reader> "change-combination-test" parse-stream drop
+ } unlines <string-reader> "change-combination-test" parse-stream drop
] unit-test
{ } [
"GENERIC#: change-combination 1 ( obj a -- b )"
"M: integer change-combination 2drop 1 ;"
"M: array change-combination 2drop 2 ;"
- } "\n" join <string-reader> "change-combination-test" parse-stream drop
+ } unlines <string-reader> "change-combination-test" parse-stream drop
] unit-test
{ 2 } [
{ 4 V{ 1 2 3 } } [ 4 V{ 1 4 2 5 3 6 } [ dupd > ] filter! ] unit-test
{ "hello world how are you" }
-[ { "hello" "world" "how" "are" "you" } " " join ] unit-test
+[ { "hello" "world" "how" "are" "you" } unwords ] unit-test
{ "hello world how are you" }
[ { "hello" "world" "how" "are" "you" } " " "" join-as ] unit-test
{ "Beginning and end" f } [ "Beginning and end" "eginning " ?tail ] unit-test
{ { "This" "is" "a" "split" "sentence" } }
-[ "This is a split sentence" " " split ]
+[ "This is a split sentence" words ]
unit-test
{ { "OneWord" } }
-[ "OneWord" " " split ]
+[ "OneWord" words ]
unit-test
{ { "a" "b" "c" "d" "e" "f" } }
[ "aXbYcXdYeXf" "XY" split ] unit-test
{ { "" "" } }
-[ " " " " split ] unit-test
+[ " " words ] unit-test
{ { "hey" } }
-[ "hey" " " split ] unit-test
+[ "hey" words ] unit-test
{ "Hello world" t } [ "Hello world\n" "\n" ?tail ] unit-test
{ "Hello world" f } [ "Hello world" "\n" ?tail ] unit-test
: unlines-as ( seq exemplar -- seq ) "\n" swap join-as ; inline
: unlines ( seq -- seq ) "" unlines-as ; inline
+: words ( seq -- seq ) " " split ; inline
+: unwords-as ( seq exemplar -- seq ) " " swap join-as ; inline
+: unwords ( seq -- seq ) " " unwords-as ; inline
[ bottles "of beer.\nTake one down, pass it around," ]
[ 1 - bottles [ >lower ] dip "of beer on the wall." ]
} cleave
- ] output>array " " join print nl ;
+ ] output>array unwords print nl ;
: last-verse ( -- )
"No more bottles of beer on the wall, no more bottles of beer." print
] if ;
: number>chameneos-string ( n -- string )
- number>string string>digits [ number>text ] { } map-as " " join ;
+ number>string string>digits [ number>text ] { } map-as unwords ;
: chameneos-redux ( n colors -- )
[ <meeting-place> ] [ make-creatures ] bi*
IN: benchmark.unicode
: crazy-unicode-string ( -- string )
- 8 [ 8 0xffff random-integers ] replicate " " join ;
+ 8 [ 8 0xffff random-integers ] replicate unwords ;
: unicode-benchmark ( -- )
crazy-unicode-string 8 [
! Squares of numbers from 0 to 100
-${ 100 [0,b] [ dup * number>string ] map "\n" join "\n" append }
+${ 100 [0,b] [ dup * number>string ] map unlines "\n" append }
[
"
++++[>+++++<-]>[<+++++>-]+<+[
IN: bunny.model
: numbers ( str -- seq )
- " " split [ string>number ] map sift ;
+ words [ string>number ] map sift ;
: (parse-model) ( vs is -- vs is )
readln [
{ f } [ H{ { 1 H{ { 3 4 } } } } { [ 1 of ] [ 2 of ] } chain ] unit-test
{ f } [ H{ { 2 H{ { 3 4 } } } } { [ 1 of ] [ 2 of ] } chain ] unit-test
{ 5 } [
- "hello factor!" { [ " " split ] [ first ] [ length ] } chain
+ "hello factor!" { [ words ] [ first ] [ length ] } chain
] unit-test
M: reference-expr expr>str value>> unparse ;
-M: sequence expr>str [ unparse ] map " " join ;
+M: sequence expr>str [ unparse ] map unwords ;
M: object expr>str unparse ;
! Process the list of strings, which should make
! up an 8080 instruction, and output a quotation
! that would implement that instruction.
- dup " " join instruction-quotations
+ dup unwords instruction-quotations
[
"_" join [ "emulate-" % % ] "" make create-word-in
dup last-instruction set-global
[ "Memory: " write cuda-device-memory number>string print ]
[
"Capability: " write
- cuda-device-capability [ number>string ] map " " join print
+ cuda-device-capability [ number>string ] map unwords print
]
[ "Properties: " write cuda-device-properties . ]
[
dup connect-opposite-edges ;
: parse-vertex ( line -- position )
- " " split first3 [ string>number >float ] tri@ 0.0 double-4-boa ;
+ words first3 [ string>number >float ] tri@ 0.0 double-4-boa ;
: read-vertex ( line vertices -- )
[ parse-vertex ] dip push ;
dup 0 >= [ nip 1 - ] [ [ length ] dip + ] if ;
: parse-face ( line vertices -- vertices )
- [ " " split ] dip '[ _ parse-face-index ] map ;
+ [ words ] dip '[ _ parse-face-index ] map ;
: read-face ( line vertices faces -- )
[ parse-face ] dip push ;
MEMO: ip-db ( -- seq )
download-db ascii file-lines
- [ "#" head? ] reject "\n" join string>csv
+ [ "#" head? ] reject unlines string>csv
[ parse-ip-entry ] map ;
: filter-overlaps ( alist -- alist' )
: commit. ( commit -- )
{
[ hash>> "commit " prepend print ]
- [ author>> "Author: " prepend " " split 2 head* " " join print ]
- [ author>> " " split git-date>string "Date: " prepend print ]
- [ message>> "\n" split [ " " prepend ] map "\n" join nl print nl ]
+ [ author>> "Author: " prepend words 2 head* unwords print ]
+ [ author>> words git-date>string "Date: " prepend print ]
+ [ message>> "\n" split [ " " prepend ] map unlines nl print nl ]
} cleave ;
ERROR: unknown-field name parameter ;
] [
[ first " " split1 ]
[ rest [ rest ] map ] bi
- swap prefix "\n" join 2array
+ swap prefix unlines 2array
] if
] map
] [
: replace-log-line-numbers ( object log -- log' )
"\n" split harvest
[ replace-log-line-number ] with map
- "\n" join ;
+ unlines ;
: gl-shader-kind ( shader-kind -- shader-kind )
{
USING: accessors arrays assocs calendar calendar.english
-calendar.format calendar.parser formatting fry grouping io
-io.crlf io.encodings.ascii io.encodings.binary
-io.encodings.string io.encodings.utf7 io.encodings.utf8
-io.sockets io.sockets.secure io.streams.duplex io.streams.string
-kernel math math.parser multiline pcre sequences
-sequences.extras strings ;
+calendar.format calendar.parser formatting grouping io io.crlf
+io.encodings.ascii io.encodings.binary io.encodings.string
+io.encodings.utf7 io.encodings.utf8 io.sockets io.sockets.secure
+io.streams.duplex io.streams.string kernel math math.parser
+multiline sequences sequences.extras splitting strings ;
QUALIFIED: pcre
IN: imap
! Special parsing
: parse-items ( seq -- items )
- first " " split 2 tail ;
+ first words 2 tail ;
: parse-list-folders ( str -- folder )
[[ \* LIST \(([^\)]+)\) "([^"]+)" "?([^"]+)"?]] pcre:findall
: parse-status ( seq -- assoc )
first [[ \* STATUS "[^"]+" \(([^\)]+)\)]] pcre:findall first last last
- " " split 2 group [ string>number ] assoc-map ;
+ words 2 group [ string>number ] assoc-map ;
: parse-store-mail-line ( str -- pair/f )
[[ \(FLAGS \(([^\)]+)\) UID (\d+)\)]] pcre:findall [ f ] [
- first rest values first2 [ " " split ] dip string>number swap 2array
+ first rest values first2 [ words ] dip string>number swap 2array
] if-empty ;
: parse-store-mail ( seq -- assoc )
drop ;
: status-folder ( mailbox keys -- assoc )
- [ >utf7imap4 ] dip " " join "STATUS \"%s\" (%s)" sprintf
+ [ >utf7imap4 ] dip unwords "STATUS \"%s\" (%s)" sprintf
"" command-response parse-status ;
: close-folder ( -- )
{
[ prefix>> ]
[ command>> ]
- [ parameters>> " " join ]
+ [ parameters>> unwords ]
[ trailing>> dup [ CHAR: : prefix ] when ]
- } cleave 4array sift " " join ;
+ } cleave 4array sift unwords ;
<PRIVATE
: ?define-irc-parameters ( class slot-names -- )
PREDICATE: action < ctcp trailing>> rest "ACTION" head? ;
M: rpl-names post-process-irc-message ( rpl-names -- )
- [ [ blank? ] trim " " split ] change-nicks drop ;
+ [ [ blank? ] trim words ] change-nicks drop ;
M: ctcp post-process-irc-message ( ctcp -- )
[ rest but-last ] change-text drop ;
: split-message ( string -- prefix command parameters trailing )
":" ?head [ " " split1 ] [ f swap ] if
":" split1
- [ " " split harvest unclip swap ] dip ;
+ [ words harvest unclip swap ] dip ;
: sender ( irc-message -- sender )
prefix>> [ ":" ?head drop "!" split-at-first drop ] [ f ] if* ;
'[ _ lcd-digit ] { } map-as concat ;
: lcd ( digit-str -- string )
- 4 <iota> [ lcd-row ] with map "\n" join ;
+ 4 <iota> [ lcd-row ] with map unlines ;
TUPLE: time-display < label timer ;
: git-id ( -- id )
{ "git" "show" } utf8 [ lines ] with-process-reader
- first " " split second ;
+ first words second ;
<PRIVATE
] with-file-writer ; inline
: file-tail ( file encoding lines -- seq )
- [ file-lines ] dip short tail* "\n" join ;
+ [ file-lines ] dip short tail* unlines ;
:: failed-report ( error file what -- status )
[
: over-1000000 ( n -- str )
3 digit-groups [ 1 + units nth n-units ] map-index sift
- reverse " " join ;
+ reverse unwords ;
: decompose ( n -- str ) 1000000 /mod [ over-1000000 ] dip
dup 0 > [ basic space-append ] [ drop ] if ;
[ drop f ]
} case [
2 group dup [ weather key? ] all?
- [ [ weather at ] map " " join ]
+ [ [ weather at ] map unwords ]
[ concat parse-glossary ] if
] dip prepend
] if ;
[ [ f ] [ low-clouds at "low clouds are %s" sprintf ] if-zero ]
[ [ f ] [ mid-clouds at "middle clouds are %s" sprintf ] if-zero ]
[ [ f ] [ high-clouds at "high clouds are %s" sprintf ] if-zero ]
- tri* 3array " " join ;
+ tri* 3array unwords ;
: parse-inches ( str -- str' )
dup [ CHAR: / = ] all? [ drop "unknown" ] [
"sea-level pressure is %s hPa" sprintf ;
: parse-lightning ( str -- str' )
- "LTG" ?head drop 2 group [ lightning at ] map " " join ;
+ "LTG" ?head drop 2 group [ lightning at ] map unwords ;
CONSTANT: re-recent-weather R/ ((\w{2})?[BE]\d{2,4}((\w{2})?[BE]\d{2,4})?)+/
: parse-recent-weather ( str -- str' )
split-recent-weather
- [ (parse-recent-weather) ] map " " join ;
+ [ (parse-recent-weather) ] map unwords ;
: parse-varying ( str -- str' )
"V" split1 [ string>number ] bi@
} cond ;
: metar-remarks ( report seq -- report )
- [ parse-remark ] map " " join >>remarks ;
+ [ parse-remark ] map unwords >>remarks ;
: <metar-report> ( metar -- report )
[ metar-report new ] dip [ >>raw ] keep
M: doctype write-html
[ open>> % ]
- [ values>> [ >value ] map " " join [ " " % % ] unless-empty ]
+ [ values>> [ >value ] map unwords [ " " % % ] unless-empty ]
[ close>> % ] tri ;
: write-props ( seq -- )
- [ dup array? [ first2 >value "=" glue ] [ >value ] if ] map " " join [ " " % % ] unless-empty ;
+ [ dup array? [ first2 >value "=" glue ] [ >value ] if ] map unwords [ " " % % ] unless-empty ;
M: open-tag write-html
{
<PRIVATE
: word>morse ( str -- morse )
- [ ch>morse ] { } map-as " " join ;
+ [ ch>morse ] { } map-as unwords ;
: sentence>morse ( str -- morse )
- " " split [ word>morse ] map " / " join ;
+ words [ word>morse ] map " / " join ;
: trim-blanks ( str -- newstr )
[ blank? ] trim ; inline
: morse>word ( morse -- str )
- " " split [ morse>ch ] "" map-as ;
+ words [ morse>ch ] "" map-as ;
: morse>sentence ( morse -- sentence )
- "/" split [ trim-blanks morse>word ] map " " join ;
+ "/" split [ trim-blanks morse>word ] map unwords ;
: replace-underscores ( str -- str' )
[ dup CHAR: _ = [ drop CHAR: - ] when ] map ;
USING: pcre.ffi sequences splitting tools.test ;
IN: pcre.ffi.tests
-{ 2 } [ pcre_version " " split length ] unit-test
+{ 2 } [ pcre_version words length ] unit-test
"/Type /Catalog"
"/Pages 15 0 R"
">>"
- } "\n" join ;
+ } unlines ;
: pdf-pages ( n -- str )
[
"/Kids [ " "]" surround ,
] bi
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: pdf-page ( n -- page )
[
"/F10 12 0 R /F11 13 0 R /F12 14 0 R" ,
">> >>" ,
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: pdf-trailer ( objects -- str )
[
"startxref" ,
[ length 1 + ] map-sum 9 + "%d" sprintf ,
"%%EOF" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
SYMBOLS: pdf-producer pdf-author pdf-creator ;
dup length [1,b] zip [ first2 pdf-object ] map ;
: objects>pdf ( objects -- str )
- [ "\n" join "\n" append "%PDF-1.4\n" ]
+ [ unlines "\n" append "%PDF-1.4\n" ]
[ pdf-trailer ] bi surround ;
! Rename to pdf>string, have it take a <pdf> object?
} cleave
"/BaseFont " prepend ,
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
M: timestamp pdf-value
"%Y%m%d%H%M%S" strftime "D:" prepend ;
M: integer >ckf ;
: parse-cards ( string -- seq )
- " " split [ >ckf ] map ;
+ words [ >ckf ] map ;
: flush? ( cards -- ? )
0xF000 [ bitand ] reduce 0 = not ;
: get-ok-and-total ( -- total )
stream [
readln dup "+OK" head? [
- " " split second string>number dup account count<<
+ words second string>number dup account count<<
] [ throw ] if
] with-stream* ;
: get-ok-and-uidl ( -- uidl )
stream [
readln dup "+OK" head? [
- " " split last
+ words last
] [ throw ] if
] with-stream* ;
: source-067 ( -- seq )
"resource:extra/project-euler/067/triangle.txt"
- ascii file-lines [ " " split [ string>number ] map ] map ;
+ ascii file-lines [ words [ string>number ] map ] map ;
PRIVATE>
ArgumentParser dup
"--foo" >py H{ { "help" "badger" } } >py add_argument
format_help py>
- ] with-destructors [ blank? ] s:trim " " split "badger" swap in?
+ ] with-destructors [ blank? ] s:trim words "badger" swap in?
] py-test
{ t } [
[ n>> ] [ generator>> ] bi
'[ _ generate-question* ] replicate ;
-: trim-blanks ( seq -- seq' ) " " split harvest " " join ;
+: trim-blanks ( seq -- seq' ) words harvest unwords ;
: first-n-letters ( n -- seq ) <iota> [ CHAR: a + 1string ] map ;
: alphabet-zip ( seq -- zip ) [ length <iota> [ CHAR: a + 1string ] { } map-as ] keep zip ;
M: question parse-response drop trim-blanks ;
M: stack-shuffler generate-question*
n-shufflers>> [ stack-shufflers random ] [ ] replicate-as
[ inputs first-n-letters ] keep
- '[ _ _ with-datastack " " join ] ;
+ '[ _ _ with-datastack unwords ] ;
M: question ask-question generated>> . ;
M: string-response ask-question generated>> . ;
: select ( seq -- seq' ) [ amb-lazy ] map ;
: search ( -- )
- words select dup sentence-match? [ " " join ] [ fail ] if . ;
+ words select dup sentence-match? [ unwords ] [ fail ] if . ;
MAIN: search
[ drop [ dup " " glue ] map ] 2bi append ;
: (sierpinski) ( triangle spaces n -- triangle' )
- dup 0 = [ 2drop "\n" join ] [
+ dup 0 = [ 2drop unlines ] [
[
[ iterate-triangle ]
[ nip dup append ] 2bi
: out? ( line -- ? ) [ "OUT" ] dip subseq? ; inline
-: line-time ( line -- time ) " " split harvest fourth ; inline
+: line-time ( line -- time ) words harvest fourth ; inline
: update-max-count ( max -- max' )
dup [ current-count>> ] [ max-count>> ] bi >
M: push-insn eval-insn value>> swons ;
: rpn-tokenize ( string -- string' )
- " " split harvest sequence>list ;
+ words harvest sequence>list ;
: rpn-parse ( string -- tokens )
rpn-tokenize [
M: object array-element>string smalltalk>string ;
M: array array-element>string
- [ array-element>string ] map " " join "(" ")" surround ;
+ [ array-element>string ] map unwords "(" ")" surround ;
M: array smalltalk>string
array-element>string "#" prepend ;
M: byte-array smalltalk>string
- [ number>string ] { } map-as " " join "#[" "]" surround ;
+ [ number>string ] { } map-as unwords "#[" "]" surround ;
M: symbol smalltalk>string
name>> smalltalk>string "#" prepend ;
?second " " split1
[ "-->" split1 [ [ blank? ] trim parse-srt-timestamp ] bi@ ]
[
- [ blank? ] trim " " split sift [
+ [ blank? ] trim words sift [
f
] [
[ ":" split1 nip string>number ] map
] if-empty
] bi*
]
- [ 2 tail "\n" join ] tri srt-chunk boa ;
+ [ 2 tail unlines ] tri srt-chunk boa ;
: parse-srt-lines ( seq -- seq' )
{ "" } split harvest
"/Author " "USER" os-env "unknown" or pdf-string append ,
"/Creator (created with Factor)" ,
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: pdf-catalog ( -- str )
{
"/Type /Catalog"
"/Pages 4 0 R"
">>"
- } "\n" join ;
+ } unlines ;
: pdf-font ( -- str )
{
"/Subtype /Type1"
"/BaseFont /Courier"
">>"
- } "\n" join ;
+ } unlines ;
: pdf-pages ( n -- str )
[
"/Kids [ " "]" surround ,
] bi
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: pdf-text ( lines -- str )
[
"12 TL" ,
[ pdf-string "'" append , ] each
"ET" ,
- ] { } make "\n" join pdf-stream ;
+ ] { } make unlines pdf-stream ;
: pdf-page ( n -- page )
[
1 + "/Contents %d 0 R" sprintf ,
"/Resources << /Font << /F1 3 0 R >> >>" ,
">>" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: pdf-trailer ( objects -- str )
[
"startxref" ,
[ length 1 + ] map-sum 9 + "%d" sprintf ,
"%%EOF" ,
- ] { } make "\n" join ;
+ ] { } make unlines ;
: string>lines ( str -- lines )
"\t" split " " join lines
dup length [1,b] zip [ first2 pdf-object ] map ;
: objects>pdf ( objects -- str )
- [ "\n" join "\n" append "%PDF-1.4\n" ]
+ [ unlines "\n" append "%PDF-1.4\n" ]
[ pdf-trailer ] bi surround ;
PRIVATE>
command-line get [
[ speak ] each-line
] [
- " " join speak
+ unwords speak
] if-empty ;
MAIN: speak-main
[ first "-n" = ] keep over [ rest ] when ;
: echo-args ( args -- )
- -n? " " join write [ nl ] unless ;
+ -n? unwords write [ nl ] unless ;
: run-echo ( -- )
command-line get [ nl ] [ echo-args ] if-empty ;
GENERIC: >txon ( object -- string )
M: sequence >txon
- [ >txon ] map "\n" join ;
+ [ >txon ] map unlines ;
M: assoc >txon
>alist [
first2 [ encode-value ] [ >txon ] bi* "%s:`%s`" sprintf
- ] map "\n" join ;
+ ] map unlines ;
M: string >txon
encode-value ;
] "" make ;
: binary-release-script ( version builders -- string )
- [ binary-release-command ] with map "\n" join ;
+ [ binary-release-command ] with map unlines ;
: do-binary-release ( version builders -- )
"Copying binary releases to release directory..." print flush
2dup >byte-array ZMQ_SUBSCRIBE swap zmq-setopt
0 100 dup [
[ pick 0 zmq-recv
- >string " " split [ string>number ] map second +
+ >string words [ string>number ] map second +
] times
] dip
/ "Average temperature for zipcode '%s' was %dF\n" printf