Web 2.0 style assoc syntax. H{ "foo" => 1 "bar" => { 2 3 } }

db4
Joe Groff 2009-04-24 15:02:53 -05:00
parent d88a89a3a0
commit ad19fd7cbd
5 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1 @@
Joe Groff

View File

@ -0,0 +1,15 @@
! (c)2009 Joe Groff bsd license
USING: help.markup help.syntax multiline ;
IN: pair-rocket
HELP: =>
{ $syntax "a => b" }
{ $description "Constructs a two-element array from the objects immediately before and after the " { $snippet "=>" } ". This syntax can be used inside sequence and assoc literals." }
{ $examples
{ $unchecked-example <" USING: pair-rocket prettyprint ;
H{ "foo" => 1 "bar" => 2 } .
"> <" H{ { "foo" 1 } { "bar" 2 } } "> }
}
;

View File

@ -0,0 +1,9 @@
USING: kernel pair-rocket tools.test ;
IN: pair-rocket.tests
[ { "a" 1 } ] [ "a" => 1 ] unit-test
[ { { "a" } { 1 } } ] [ { "a" } => { 1 } ] unit-test
[ { drop 1 } ] [ drop => 1 ] unit-test
[ H{ { "zippity" 5 } { "doo" 2 } { "dah" 7 } } ]
[ H{ "zippity" => 5 "doo" => 2 "dah" => 7 } ] unit-test

View File

@ -0,0 +1,6 @@
! (c)2009 Joe Groff bsd license
USING: arrays kernel parser sequences ;
IN: pair-rocket
SYNTAX: => dup pop scan-object 2array parsed ;

View File

@ -0,0 +1 @@
H{ "foo" => 1 "bar" => 2 } style literal syntax