Memoize |
BasicWerk
EC Support
Technique
Facebook
|
20140617144844_factor_memo_2map_lexical_vars |
|
factor_memo_2map_lexical_vars
IN: scratchpad auto-use { 1 2 3 } qw{ a b c } [ 2array ] 2map .
{ { 1 "a" } { 2 "b" } { 3 "c" } }
: with-current-db ( db-name quot -- )
swap absolute-path
temp-file <sqlite-db> swap with-db
; inline
IN: scratchpad auto-use
"sample.db"
[
"select * from foo" sql-query
dup length [1,b] swap [ 2array ] 2map
] with-current-db .
{
{ 1 { "1" "Mary" "33" } }
{ 2 { "2" "Ann" "27" } }
{ 3 { "3" "John" "69" } }
{ 4 { "88" "Yasohachi" "88" } }
{ 5 { "888" "Yaoya" "808" } }
}
N: scratchpad auto-use
"sample.db"
[
"select * from foo" sql-query
dup length [1,b] [ prefix ] 2map
] with-current-db .
{
{ 1 "1" "Mary" "33" }
{ 2 "2" "Ann" "27" }
{ 3 "3" "John" "69" }
{ 4 "88" "Yasohachi" "88" }
{ 5 "888" "Yaoya" "808" }
}
IN: scratchpad auto-use "sample.db" [ "select * from foo" sql-query dup length [1,b] [ prefix ] 2map ] with-current-db
--- Data stack:
{ ~array~ ~array~ ~array~ ~array~ ~array~ }
IN: scratchpad auto-use
[
[ ] each ! array -> stack
[| cnt id name age |
cnt 2 mod 0 =
[ name print ] when
] call
] each
Ann
Yasohachi
|
| © Shin Nakamura/BasicWerk 2014 |