https://github.com/magnusmorton/trace-analysis
Raw File
Tip revision: 4645af99638edea16d00e811c922b0fb9d6b86d9 authored by Magnus Morton on 11 January 2016, 20:33:10 UTC
subplots and recording output
Tip revision: 4645af9
crossproduct.rkt
#lang racket/base

(define SIZE (string->number (vector-ref (current-command-line-arguments) 0 )))

(define (mk-list size v)
  (if (= 0 size)
      null
      (cons v (mk-list (- size 1) v))
      )
  )

(define vec1 (mk-list SIZE 3))
(define vec2 (mk-list SIZE 5))


;; (define (cross-product l r)
;;  (map  (lambda (lnum)(time (foldl (lambda (acc rnum) (+ acc ( * lnum rnum ))) 0 r))) l))

(define (cross-product l r)
    (for/vector ([i l]
               [j r])
        (* i j)))
        

;; dot-product works on sequences such as vectors:
(cross-product vec1 vec2)
back to top