HCoop
/
jackhill
/
mal.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bb95e7a
)
vimscript: add seq and string?
author
Dov Murik
<dov.murik@gmail.com>
Fri, 12 Feb 2016 14:29:45 +0000
(09:29 -0500)
committer
Dov Murik
<dov.murik@gmail.com>
Fri, 12 Feb 2016 15:16:05 +0000
(10:16 -0500)
Issue #166
vimscript/core.vim
patch
|
blob
|
blame
|
history
diff --git
a/vimscript/core.vim
b/vimscript/core.vim
index
f29fc47
..
8925d14
100644
(file)
--- a/
vimscript/core.vim
+++ b/
vimscript/core.vim
@@
-248,6
+248,10
@@
function MalSymbolQ(args)
return BoolNew(SymbolQ(a:args[0]))
endfunction
return BoolNew(SymbolQ(a:args[0]))
endfunction
+function MalStringQ(args)
+ return BoolNew(StringQ(a:args[0]))
+endfunction
+
function MalKeyword(args)
return KeywordNew(ObjValue(a:args[0]))
endfunction
function MalKeyword(args)
return KeywordNew(ObjValue(a:args[0]))
endfunction
@@
-280,6
+284,20
@@
function MalConj(args)
endif
endfunction
endif
endfunction
+function MalSeq(args)
+ let obj = a:args[0]
+ if EmptyQ(obj)
+ return g:MalNil
+ elseif ListQ(obj)
+ return obj
+ elseif VectorQ(obj)
+ return ListNew(ObjValue(obj))
+ elseif StringQ(obj)
+ return ListNew(map(split(ObjValue(obj), '\zs'), 'StringNew(v:val)'))
+ endif
+ throw "seq requires string or list or vector or nil"
+endfunction
+
function MalMeta(args)
return ObjMeta(a:args[0])
endfunction
function MalMeta(args)
return ObjMeta(a:args[0])
endfunction
@@
-360,6
+378,7
@@
let CoreNs = {
\ "false?": NewNativeFn("MalFalseQ"),
\ "symbol": NewNativeFn("MalSymbol"),
\ "symbol?": NewNativeFn("MalSymbolQ"),
\ "false?": NewNativeFn("MalFalseQ"),
\ "symbol": NewNativeFn("MalSymbol"),
\ "symbol?": NewNativeFn("MalSymbolQ"),
+ \ "string?": NewNativeFn("MalStringQ"),
\ "keyword": NewNativeFn("MalKeyword"),
\ "keyword?": NewNativeFn("MalKeywordQ"),
\ "list": NewNativeFn("MalList"),
\ "keyword": NewNativeFn("MalKeyword"),
\ "keyword?": NewNativeFn("MalKeywordQ"),
\ "list": NewNativeFn("MalList"),
@@
-393,6
+412,7
@@
let CoreNs = {
\ "map": NewNativeFn("MalMap"),
\ "throw": NewNativeFn("MalThrow"),
\ "conj": NewNativeFn("MalConj"),
\ "map": NewNativeFn("MalMap"),
\ "throw": NewNativeFn("MalThrow"),
\ "conj": NewNativeFn("MalConj"),
+ \ "seq": NewNativeFn("MalSeq"),
\ "meta": NewNativeFn("MalMeta"),
\ "with-meta": NewNativeFn("MalWithMeta"),
\ "atom": NewNativeFn("MalAtom"),
\ "meta": NewNativeFn("MalMeta"),
\ "with-meta": NewNativeFn("MalWithMeta"),
\ "atom": NewNativeFn("MalAtom"),