Permalink
Browse files

Improved wrap and added a join function

  • Loading branch information...
1 parent 143bc09 commit 07fa857e359dd399f4d58d382fdbbedb0da5fbac @hawx committed May 12, 2012
Showing with 10 additions and 3 deletions.
  1. +8 −1 boot.vk
  2. +1 −1 interpreter.go
  3. +1 −1 types.go
View
@@ -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.
@@ -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
View
@@ -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()
},
View
@@ -93,7 +93,7 @@ type VBlock struct {
}
func (v *VBlock) String() string {
- return "block:[ " + v.value + " ]"
+ return "[ " + v.value + " ]"
}
func (v *VBlock) Value() interface{} {

0 comments on commit 07fa857

Please sign in to comment.