Skip to content

Commit

Permalink
core: rest
Browse files Browse the repository at this point in the history
  • Loading branch information
candid82 committed May 3, 2016
1 parent cfa2bd6 commit 83edbf9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@
^{:arglists '([x seq])
:doc "Returns a new seq where x is the first element and seq is
the rest."
:added "1.0"
:static true}
:added "1.0"}
cons cons)

(def
^{:arglists '([coll])
:doc "Returns the first item in the collection. Calls seq on its
argument. If coll is nil, returns nil."
:added "1.0"
:static true}
:added "1.0"}
first first)

(def
^{:arglists '([coll])
:doc "Returns a seq of the items after the first. Calls seq on its
argument. If there are no more items, returns nil."
:added "1.0"
:static true}
:added "1.0"}
next next)

(def
^{:arglists '([coll])
:doc "Returns a possibly empty seq of the items after the first. Calls seq on its
argument."
:added "1.0"}
rest rest)


7 changes: 7 additions & 0 deletions procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ var procNext Proc = func(args []Object) Object {
return res
}

var procRest Proc = func(args []Object) Object {
checkArity(args, 1, 1)
s := ensureSeq(args[0], "rest's argument must be sequenceable")
return s.Rest()
}

var coreNamespace = GLOBAL_ENV.namespaces[MakeSymbol("gclojure.core").name]

func intern(name string, proc Proc) {
Expand All @@ -176,6 +182,7 @@ func init() {
intern("cons", procCons)
intern("first", procFirst)
intern("next", procNext)
intern("rest", procRest)

intern("meta", procMeta)
intern("zero?", procIsZero)
Expand Down

0 comments on commit 83edbf9

Please sign in to comment.