R3 compatible MAP
; R3-compatible interface
map: func ['word data [block!] body [block!]] [
collect/only res compose/deep [
repeat (word) data [res: do bind/copy body (to lit-word! word)]
]
]
11348 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
; R3-compatible interface
map: func ['word data [block!] body [block!]] [
collect/only res compose/deep [
repeat (word) data [res: do bind/copy body (to lit-word! word)]
]
]
merge: func [ "Merge A and B together, like a zipper, alternating elements" a [series!] b [series!] /only "Merge items as sub-blocks" /local res val ][ res: make a length? a repeat i max length? a length? b [ val: reduce [pick a i pick b i] either only [append/only res val] [append res val] ] res ]
; You could use split-path for this, but it's a bit non- ; orthogonal in what it returns when there's no path. has-path?: func [file [file!]] [find file #"/"]
script-name: does [system/options/script]
boot-path: does [system/options/path]
REBOL-EXE: does [system/options/boot]
username: does [get-env "USERNAME"]
machine-id: does [read dns://]
incr: func [ {Increment a value by 1.} :word [lit-word!] /by {Change by this amount} ; /skip ? value ][ set word add get word any [value 1] ] ;>> a: 0 ;== 0 ;>> incr a ;** Script Error: incr expected word argument of type: ;lit-word ;** Near: incr a ;>> incr 'a ;== 1
days-in-months: [31 28 31 30 31 30 31 31 30 31 30 31] days-in-months-leap: head change at copy days-in-months 2 29 days-up-to-month: func [month /in year] [ sum copy/part either leap-year?/with any [year now] [days-in-months-leap] [days-in-months] month - 1 ]