- test that *ARGV* gets set properly
- test to make sure slurp captures final newline
- - fix long line splitting in runtest
- Give runtest knowledge of optional tests and report as non-fatal
- regular expression matching in runtest
- add re (use in rep) everywhere and use that (to avoid printing)
exc)))
;; Sequence functions
+(define do_apply
+ (lambda a
+ (let* ([f (first a)]
+ [lst (_to_list (last a))]
+ [args (append (take (drop a 1) (- (length a) 2)) lst)])
+ (apply f args))))
+
(define conj
(lambda a
(if (vector? (first a))
'rest _rest
'empty? _empty?
'count _count
- 'apply apply
+ 'apply do_apply
'map (lambda (f s) (_to_list (_map f s)))
'conj conj
;=>5
(apply + 4 (list 5))
;=>9
-(apply + 4 [5])
-;=>9
(apply prn (list 1 2 "3" (list)))
; 1 2 "3" ()
(apply prn 1 2 (list "3" (list)))
; 1 2 "3" ()
-(apply prn 1 2 ["3" 4])
-; 1 2 "3" 4
-;=>nil
;; Testing apply function with user functions
(apply (fn* (a b) (+ a b)) (list 2 3))
;=>5
(apply (fn* (a b) (+ a b)) 4 (list 5))
;=>9
-(apply (fn* (a b) (+ a b)) [2 3])
-;=>5
-(apply (fn* (a b) (+ a b)) 4 [5])
-;=>9
;; Testing map function
(def! nums (list 1 2 3))
(sequential? "abc")
;=>false
+;; Testing apply function with core functions and arguments in vector
+(apply + 4 [5])
+;=>9
+(apply prn 1 2 ["3" 4])
+; 1 2 "3" 4
+;=>nil
+;; Testing apply function with user functions and arguments in vector
+(apply (fn* (a b) (+ a b)) [2 3])
+;=>5
+(apply (fn* (a b) (+ a b)) 4 [5])
+;=>9
+
;; Testing map function with vectors
(map (fn* (a) (* 2 a)) [1 2 3])