File tree Expand file tree Collapse file tree
Clojure.Tests/clojure/test_clojure Expand file tree Collapse file tree Original file line number Diff line number Diff line change 31883188 {:added " 1.3"
31893189 :static true }
31903190 [coll n]
3191- (if (instance? clojure.lang.IDrop coll)
3192- (if (pos? n)
3193- (or (.drop ^clojure.lang.IDrop coll (if (int? n) n (Math/Ceiling (. clojure.lang.RT (doubleCast n))))) ()) ; ;; Math/ceil -- added doubleCast
3194- coll)
3195- (loop [n n xs coll]
3196- (if-let [xs (and (pos? n) (seq xs))]
3197- (recur (dec n) (rest xs))
3198- xs))))
3191+ (if (pos? n)
3192+ (or
3193+ (if (instance? clojure.lang.IDrop coll)
3194+ (.drop ^clojure.lang.IDrop coll (if (int? n) n (Math/Ceiling (. clojure.lang.RT (doubleCast n))))) ; ;; Math/ceil -- added doubleCast
3195+ (loop [n n xs coll]
3196+ (if-let [xs (and (pos? n) (seq xs))]
3197+ (recur (dec n) (rest xs))
3198+ (seq xs))))
3199+ ())
3200+ coll))
31993201
32003202(defn partition
32013203 " Returns a lazy sequence of lists of n items each, at offsets step
Original file line number Diff line number Diff line change 413413 (next (to-array [(into-array []) nil ])) '(nil )
414414 (next (to-array [(into-array []) 2 nil ])) '(2 nil ) ))
415415
416+ (deftest test-nthnext+rest-on-0
417+ (are [coll]
418+ (and (= (seq coll) (nthnext coll 0 ))
419+ (= coll (nthrest coll 0 )))
420+ nil
421+ " "
422+ ()
423+ '(0 )
424+ []
425+ [0 ]
426+ #{}
427+ {}
428+ {:a 1 }
429+ (range 5 )))
430+
431+ (deftest test-nthnext+rest-on-pos
432+ (are [coll n nthnext-expected nthrest-expected]
433+ (and (= nthnext-expected (nthnext coll n))
434+ (= nthrest-expected (nthrest coll n)))
435+
436+ ; coll n nthnext nthrest
437+ nil 1 nil ()
438+ " abc" 1 '(\b \c) '(\b \c)
439+ " abc" 3 nil ()
440+ " abc" 4 nil ()
441+ () 1 nil ()
442+ '(1 ) 1 nil ()
443+ '(1 ) 2 nil ()
444+ '(()) 1 nil ()
445+ #{} 1 nil ()
446+ {:a 1 } 1 nil ()
447+ [] 1 nil ()
448+ [0 ] 1 nil ()
449+ [0 ] 2 nil ()
450+ [[] 2 nil ] 1 '(2 nil ) '(2 nil )
451+ [[] 2 nil ] 2 '(nil ) '(nil )
452+ [[] 2 nil ] 3 nil ()
453+ (sorted-set 1 2 3 ) 2 '(3 ) '(3 )
454+ (sorted-map :a 1 :b 2 ) 1 '([:b 2 ]) '([:b 2 ])
455+ (into-array []) 1 nil ()
456+ (into-array [1 ]) 1 nil ()
457+ (range 5 ) 3 '(3 4 ) '(3 4 )
458+ (range 5 ) 5 nil ()))
416459
417460(deftest test-last
418461 (are [x y] (= x y)
You can’t perform that action at this time.
0 commit comments