-
Notifications
You must be signed in to change notification settings - Fork 1
/
block-to-string.red
56 lines (44 loc) · 1 KB
/
block-to-string.red
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Red [
Title: "block-to-string"
Purpose: {
}
Alias: [
]
Build: 0.0.0.2.1
History-Latest: [
0.0.0.2.2 {Do: fix error with empty block passed}
0.0.0.2 {form block/1}
0.0.0.1 {Initial build}
]
Notes: [
>1: {
do-trace 49 ?? out for block-to-string [] ","
->
[]
weird would think "" instead
}
]
]
.block-to-string: function [/block >block /delimiter >delimiter][
{Example:
r: .block-to-string/block/delimiter ["a" "b"] ","
? r
}
.block: >block
.delimiter: >delimiter
n: length? .block
cum: collect [
forall .block [
either .block = (back tail .block) [
keep form .block/1
][
keep rejoin [form .block/1 .delimiter]
]
]
]
out: rejoin cum
return out
]
block-to-string: function[>block >delimiter][
.block-to-string/block/delimiter >block >delimiter
]