Public Vars

Back

take-last (clj)

(source)

function

(take-last n coll)
Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/take (t/All [x] (t/IFn [t/Int :-> (t/Transducer x x)]
                          [t/Int (t/Seqable x) :-> (t/ASeq x)]))
cc/drop (t/All [x] (t/IFn [t/Int :-> (t/Transducer x x)]
                          [t/Int (t/Seqable x) :-> (t/ASeq x)]))
cc/take-last (t/All [x] [t/Int (t/Seqable x) :-> (t/NilableNonEmptyASeq x)])
cc/drop-last (t/All [x] [(t/? t/Int) (t/Seqable x) :-> (t/ASeq x)])
probprog/anglican-examples
;; @@
(ns random-walks
  (:use [anglican core runtime emit stat])
  (:require [clojure.core.matrix :as mat]
            [gorilla-plot.core :as plot]))

(def worst (map :result (take-last 5 
                                   (sort-by :log-weight > smc-results))))
polygloton/calendar-logic
(ns calendar-logic.test.arithmetic.mod-test
  (:refer-clojure :exclude [== mod])
  (:use
    clojure.test
    calendar-logic.test.test-helper
    [calendar-logic.arithmetic :only [mod]]
    [clojure.core.logic :exclude [is]])
  (:require
    [clojure.core.logic.fd :as fd]))

  (eg
    (take-last 10
      (run* [x y]
        (fd/in x y (fd/interval 1 100))
        (fd/< y x)
        (mod x y 10)))
    => [[98 22] [100 18] [96 86] [98 44] [97 87] [100 30] [100 45] [98 88] [99 89] [100 90]]))