formatting: support other sequences in printf.

master
John Benediktsson 2020-03-24 11:11:15 -07:00
parent 5cc97a4d1b
commit 5525313757
2 changed files with 2 additions and 1 deletions

View 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

View 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 ] ]]