Skip to content

Commit

Permalink
Improved wrap and added a join function
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed May 12, 2012
1 parent 143bc09 commit 07fa857
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion boot.vk
Expand Up @@ -108,7 +108,7 @@

; Composes the two blocks at the top of the stack, forming one single block.
; sig: block block -> block
; example: [ dup dec ] :mult compose ;=> [block:[ dup dec mult ]]
; example: [ dup dec ] :mult compose ;=> [[ dup dec mult ]]
'compose' __document__

; Wraps the block in another block.
Expand Down Expand Up @@ -384,6 +384,13 @@
; example: 'Hello' ' World' concat ;=> ['Hello World']
'concat' __document__

; Joins all strings in a list together using the string at the top.
; sig: list string -> string
; example: ('John' 'Dave' 'Luke') ', ' join ;=> ['John, Dave, Luke']
'join' [
wrap [ swap concat concat ] compose reduce
] define


; group: Lists

Expand Down
2 changes: 1 addition & 1 deletion interpreter.go
Expand Up @@ -93,7 +93,7 @@ func BootedTable() *Table {
},
"wrap": func(s *Stack, t *Table) VType {
b := s.Pop()
r := NewVBlock("[" + b.(*VBlock).value + "]")
r := NewVBlock(b.String())
s.Push(r)
return VNil()
},
Expand Down
2 changes: 1 addition & 1 deletion types.go
Expand Up @@ -93,7 +93,7 @@ type VBlock struct {
}

func (v *VBlock) String() string {
return "block:[ " + v.value + " ]"
return "[ " + v.value + " ]"
}

func (v *VBlock) Value() interface{} {
Expand Down

0 comments on commit 07fa857

Please sign in to comment.