diff --git a/array.scm b/array.scm index b38ee90..75b2f5e 100644 --- a/array.scm +++ b/array.scm @@ -53,6 +53,14 @@ ((_ array lin col val) (vector-set! (vector-ref array lin) col val)))) +;; Scheme+ version +;; create a vector of line and column with a function +;; (define (create-vector-2d fct lin col) +;; {v <+ (make-array-2d lin col)} +;; (for ({l <+ 0} {l < lin} {l <- l + 1}) +;; (for ({c <+ 0} {c < col} {c <- c + 1}) +;; {v[l][c] <- (fct l c)})) +;; v) ;; create a vector (or array) of line and column with a function (define (create-vector-2d fct lin col) diff --git a/overload.rkt b/overload.rkt index d3ee63f..acc686e 100644 --- a/overload.rkt +++ b/overload.rkt @@ -197,7 +197,9 @@ -;; args must be the same number as predicates and their types must match +;; args must be the same number as predicates and their types must match +;; (check-arguments '() '()) +;; #t (define (check-arguments pred-list args) ;;(display "pred-list=") (display pred-list) (newline) ;;(display "args=")(display args) (newline) @@ -766,6 +768,22 @@ ;; > {Mv[1 0]} ;; 4 +;; > (overload-square-brackets matrix-vect-ref matrix-vect-set! (matrix-vect? number? number?)) +;; > (define Mv (matrix-vect (vector (vector 1 2 3) (vector 4 5 6)))) +;; > (matrix-vect-v Mv) +;; '#(#(1 2 3) #(4 5 6)) +;; > {Mv[1 0] <- -7} +;; -7 +;; > (matrix-vect-v Mv) +;; '#(#(1 2 3) #(-7 5 6)) +;; > {Mv[1][0] <- 10} +;; . . ../../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/overload.rkt:820:13: $bracket-apply$: no matching found in $ovrld-square-brackets-lst$ : failed with those arguments list (# 1) +;; > (overload-square-brackets matrix-vect-line-ref matrix-vect-line-set! (matrix-vect? number?)) +;; > {Mv[1][0] <- 10} +;; 10 +;; > (matrix-vect-v Mv) +;; '#(#(1 2 3) #(10 5 6)) + (define-syntax overload-square-brackets (syntax-rules ()