]> gitweb.factorcode.org Git - factor.git/commitdiff
formatting: support other sequences in printf.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 24 Mar 2020 18:11:15 +0000 (11:11 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 24 Mar 2020 18:11:15 +0000 (11:11 -0700)
basis/formatting/formatting-tests.factor
basis/formatting/formatting.factor

index 80b5e41c0649ba013dffcf9148f8dd1486b5bad2..96666a4594eac209a19bb381a221c10346cc7552 100644 (file)
@@ -143,6 +143,7 @@ IN: formatting.tests
 { "[####monkey]" } [ "monkey" "[%'#10s]" sprintf ] unit-test
 { "[many monke]" } [ "many monkeys" "[%10.10s]" sprintf ] unit-test
 
+{ "{ 1, 2, 3 }" } [ BV{ 1 2 3 } "%[%d, %]" sprintf ] unit-test
 { "{ 1, 2, 3 }" } [ { 1 2 3 } "%[%s, %]" sprintf ] unit-test
 { "{ 1:2, 3:4 }" } [ H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf ] unit-test
 
index 5b9b722f89fb9412071758e46adfa6a784fd0103..34fdbef9d4f7ad3089db65debd289532430f82fd 100644 (file)
@@ -136,7 +136,7 @@ numbers   = sign pad numbers_    => [[ unclip-last prefix compose-all [ fix-sign
 
 types     = strings|numbers
 
-lists     = "[%" types ", %]"    => [[ second '[ _ map ", " join "{ " prepend " }" append ] ]]
+lists     = "[%" types ", %]"    => [[ second '[ _ { } map-as ", " join "{ " " }" surround ] ]]
 
 assocs    = "[%" types ": %" types " %]" => [[ [ second ] [ fourth ] bi '[ unzip [ _ map ] dip _ map zip [ ":" join ] map ", " join "{ " prepend " }" append ] ]]