2010-11-22

« »

(define (sequence:= first rest empty? = . sequences)
  (or (null? sequences) ; special case

      (let lp1 ((sa (car sequences)) (others (cdr sequences)))
	(or (null? others)
	    (let ((sb0 (car others))
		  (others (cdr others)))
	      (if (eq? sa sb0)	; EQ? => sequence:=
		  (lp1 sb0 others)
		  (let lp2 ((sa sa) (sb sb0))
		    (if (empty? sa)
			(and (empty? sb)
			     (lp1 sb0 others))
			(and (not (empty? sb))
			     (= (first sa) (first sb))
			     (lp2 (rest sa) (rest sb)))))))))))

(define (list:= = . lists)
  (apply sequence:= car cdr null-list? = lists))

;; More wierd
(define (vector:= = . vectors)
  (define (first x) (vector-ref (cdr x) (car x)))
  (define (rest x) (cons (+ (car x) 1) (cdr x)))
  (define (empty? x) (eqv? (vector-length (cdr x)) (car x)))
  (apply sequence:= first rest empty? = (map (lambda (v) (cons 0 v)) vectors)))

« »

2016-02
2015-11
2015-10
2015-08
2015-01
2014-11
2014-09
2014-08
2014-07
2014-06
2014-05
2014-04
2014-03
2014-02
2014-01
2013-12
2013-11
2013-10
2013-09
2013-08
2013-07
2013-06
2013-05
2013-04
2013-02
2013-01
2012-12
2012-11
2012-10
2012-09
2012-08
2012-07
2012-06
2012-05
2012-04
2012-03
2012-02
2012-01
2011-12
2011-11
2011-10
2011-08
2011-07
2011-06
2011-03
2011-02
2011-01
2010-12
2010-11
2010-10
2008-07
2006-09