Last active
November 28, 2016 01:59
-
-
Save ympbyc/268322cf21a1a2e5d478 to your computer and use it in GitHub Desktop.
It worked!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cljs.core.typed.test.ympbyc.cljs-core | |
(:require-macros [cljs.core.typed :refer [ann] :as ct]) | |
(:require [cljs.core.typed :refer [All U IFn]] | |
[cljs.core :refer [IVector ISeq]])) | |
(ann cljs.core/seq (All [x] [(U (ISeq x) (IVector x)) -> (ISeq x)])) | |
(ann cljs.core/first | |
(All [x] [(U (ISeq x) (IVector x)) -> (U nil x)])) | |
;;(ann cljs.core/second ) ...etc... | |
(ann cljs.core/rest (All [x] | |
[(U (ISeq x) (IVector x)) -> (ISeq x)])) | |
(ann cljs.core/last (All [x] | |
[(U (ISeq x) (IVector x)) -> (U nil x)])) | |
(ann cljs.core/butlast (All [x] | |
[(U (ISeq x) (IVector x)) -> (ISeq x)])) | |
;;first | |
(ann vec-fst (U nil number)) | |
(def vec-fst (first [8])) | |
(ann seq-fst (U nil number)) | |
(def seq-fst (first (seq [1 2 3]))) | |
(ann fst-nil (U nil number)) | |
(def fst-nil (first [])) | |
;;rest | |
(ann vec-rest (ISeq number)) | |
(def vec-rest (rest [1 2 3])) | |
(ann seq-rest (ISeq number)) | |
(def seq-rest (rest (seq [1 2 3]))) | |
(ann rest-empty (ISeq nil)) | |
(def rest-empty (rest [])) | |
;;last | |
(ann vec-last (U nil number)) | |
(def vec-last (last [1 2 3])) | |
(ann seq-last (U nil number)) | |
(def seq-last (last (seq [1 2 3]))) | |
(ann last-nil (U nil number)) | |
(def last-nil (last [])) | |
;;butlast | |
(ann vec-butlast (ISeq number)) | |
(def vec-butlast (butlast [1 2 3])) | |
(ann seq-butlast (ISeq number)) | |
(def vec-butlast (butlast (seq [1 2 3]))) | |
(ann butlast-empty (ISeq nil)) | |
(def butlast-empty (butlast [])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment