082.scm 699 B

12345678910111213141516171819202122232425262728
  1. ;; Path sum: two ways
  2. (define (make-min-sum-array array)
  3. ())
  4. (define (init-min-path-array array)
  5. (let ((min-path-array (make-array #f
  6. (array-length array)
  7. (array-length array))))
  8. (do ((i 0 (1+ i)))
  9. ((>= i (array-length array)))
  10. (array-set! min-path-array (array-ref array i 0) i 0))
  11. min-path-array))
  12. (define (print-array array)
  13. (for-each (lambda (row)
  14. (display row) (newline))
  15. (array->list array)))
  16. (define default-array
  17. (list->array 2
  18. (list
  19. (list 131 673 234 103 18)
  20. (list 201 96 342 965 150)
  21. (list 630 803 746 422 111)
  22. (list 537 699 497 121 956)
  23. (list 805 732 524 37 331))))
  24. (print-array (init-min-path-array default-array))