25.op-ctor.upstream.scm 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. ;;; Copyright (C) Jussi Piitulainen (2001). All Rights Reserved.
  2. ;;; Permission is hereby granted, free of charge, to any person obtaining a copy
  3. ;;; of this software and associated documentation files (the "Software"), to
  4. ;;; deal in the Software without restriction, including without limitation the
  5. ;;; rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  6. ;;; sell copies of the Software, and to permit persons to whom the Software is
  7. ;;; furnished to do so, subject to the following conditions:
  8. ;;; The above copyright notice and this permission notice shall be included in
  9. ;;; all copies or substantial portions of the Software.
  10. ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14. ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  15. ;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  16. ;;; IN THE SOFTWARE.
  17. (begin
  18. (define array:opt-args '(ctor (4)))
  19. (define (array:optimize f r)
  20. (case r
  21. ((0) (let ((n0 (f))) (array:0 n0)))
  22. ((1) (let ((n0 (f 0))) (array:1 n0 (- (f 1) n0))))
  23. ((2)
  24. (let ((n0 (f 0 0)))
  25. (array:2 n0 (- (f 1 0) n0) (- (f 0 1) n0))))
  26. ((3)
  27. (let ((n0 (f 0 0 0)))
  28. (array:3
  29. n0
  30. (- (f 1 0 0) n0)
  31. (- (f 0 1 0) n0)
  32. (- (f 0 0 1) n0))))
  33. (else
  34. (let ((v
  35. (do ((k 0 (+ k 1)) (v '() (cons 0 v)))
  36. ((= k r) v))))
  37. (let ((n0 (apply f v)))
  38. (apply
  39. array:n
  40. n0
  41. (array:coefficients f n0 v v)))))))
  42. (define (array:optimize-empty r)
  43. (let ((x (make-vector (+ r 1) 0)))
  44. (vector-set! x r -1)
  45. x))
  46. (define (array:coefficients f n0 vs vp)
  47. (case vp
  48. ((()) '())
  49. (else
  50. (set-car! vp 1)
  51. (let ((n (- (apply f vs) n0)))
  52. (set-car! vp 0)
  53. (cons n (array:coefficients f n0 vs (cdr vp)))))))
  54. (define (array:vector-index x ks)
  55. (do ((sum 0 (+ sum (* (vector-ref x k) (car ks))))
  56. (ks ks (cdr ks))
  57. (k 0 (+ k 1)))
  58. ((null? ks) (+ sum (vector-ref x k)))))
  59. (define (array:shape-index) '#(2 1 0))
  60. (define (array:empty-shape-index) '#(0 0 -1))
  61. (define (array:shape-vector-index x r k)
  62. (+
  63. (* (vector-ref x 0) r)
  64. (* (vector-ref x 1) k)
  65. (vector-ref x 2)))
  66. (define (array:actor-index x k)
  67. (+ (* (vector-ref x 0) k) (vector-ref x 1)))
  68. (define (array:0 n0) (vector n0))
  69. (define (array:1 n0 n1) (vector n1 n0))
  70. (define (array:2 n0 n1 n2) (vector n1 n2 n0))
  71. (define (array:3 n0 n1 n2 n3) (vector n1 n2 n3 n0))
  72. (define (array:n n0 n1 n2 n3 n4 . ns)
  73. (apply vector n1 n2 n3 n4 (append ns (list n0))))
  74. (define (array:maker r)
  75. (case r
  76. ((0) array:0)
  77. ((1) array:1)
  78. ((2) array:2)
  79. ((3) array:3)
  80. (else array:n)))
  81. (define array:indexer/vector
  82. (let ((em
  83. (vector
  84. (lambda (x i) (+ (vector-ref x 0)))
  85. (lambda (x i)
  86. (+
  87. (* (vector-ref x 0) (vector-ref i 0))
  88. (vector-ref x 1)))
  89. (lambda (x i)
  90. (+
  91. (* (vector-ref x 0) (vector-ref i 0))
  92. (* (vector-ref x 1) (vector-ref i 1))
  93. (vector-ref x 2)))
  94. (lambda (x i)
  95. (+
  96. (* (vector-ref x 0) (vector-ref i 0))
  97. (* (vector-ref x 1) (vector-ref i 1))
  98. (* (vector-ref x 2) (vector-ref i 2))
  99. (vector-ref x 3)))
  100. (lambda (x i)
  101. (+
  102. (* (vector-ref x 0) (vector-ref i 0))
  103. (* (vector-ref x 1) (vector-ref i 1))
  104. (* (vector-ref x 2) (vector-ref i 2))
  105. (* (vector-ref x 3) (vector-ref i 3))
  106. (vector-ref x 4)))
  107. (lambda (x i)
  108. (+
  109. (* (vector-ref x 0) (vector-ref i 0))
  110. (* (vector-ref x 1) (vector-ref i 1))
  111. (* (vector-ref x 2) (vector-ref i 2))
  112. (* (vector-ref x 3) (vector-ref i 3))
  113. (* (vector-ref x 4) (vector-ref i 4))
  114. (vector-ref x 5)))
  115. (lambda (x i)
  116. (+
  117. (* (vector-ref x 0) (vector-ref i 0))
  118. (* (vector-ref x 1) (vector-ref i 1))
  119. (* (vector-ref x 2) (vector-ref i 2))
  120. (* (vector-ref x 3) (vector-ref i 3))
  121. (* (vector-ref x 4) (vector-ref i 4))
  122. (* (vector-ref x 5) (vector-ref i 5))
  123. (vector-ref x 6)))
  124. (lambda (x i)
  125. (+
  126. (* (vector-ref x 0) (vector-ref i 0))
  127. (* (vector-ref x 1) (vector-ref i 1))
  128. (* (vector-ref x 2) (vector-ref i 2))
  129. (* (vector-ref x 3) (vector-ref i 3))
  130. (* (vector-ref x 4) (vector-ref i 4))
  131. (* (vector-ref x 5) (vector-ref i 5))
  132. (* (vector-ref x 6) (vector-ref i 6))
  133. (vector-ref x 7)))
  134. (lambda (x i)
  135. (+
  136. (* (vector-ref x 0) (vector-ref i 0))
  137. (* (vector-ref x 1) (vector-ref i 1))
  138. (* (vector-ref x 2) (vector-ref i 2))
  139. (* (vector-ref x 3) (vector-ref i 3))
  140. (* (vector-ref x 4) (vector-ref i 4))
  141. (* (vector-ref x 5) (vector-ref i 5))
  142. (* (vector-ref x 6) (vector-ref i 6))
  143. (* (vector-ref x 7) (vector-ref i 7))
  144. (vector-ref x 8)))
  145. (lambda (x i)
  146. (+
  147. (* (vector-ref x 0) (vector-ref i 0))
  148. (* (vector-ref x 1) (vector-ref i 1))
  149. (* (vector-ref x 2) (vector-ref i 2))
  150. (* (vector-ref x 3) (vector-ref i 3))
  151. (* (vector-ref x 4) (vector-ref i 4))
  152. (* (vector-ref x 5) (vector-ref i 5))
  153. (* (vector-ref x 6) (vector-ref i 6))
  154. (* (vector-ref x 7) (vector-ref i 7))
  155. (* (vector-ref x 8) (vector-ref i 8))
  156. (vector-ref x 9)))))
  157. (it
  158. (lambda (w)
  159. (lambda (x i)
  160. (+
  161. (* (vector-ref x 0) (vector-ref i 0))
  162. (* (vector-ref x 1) (vector-ref i 1))
  163. (* (vector-ref x 2) (vector-ref i 2))
  164. (* (vector-ref x 3) (vector-ref i 3))
  165. (* (vector-ref x 4) (vector-ref i 4))
  166. (* (vector-ref x 5) (vector-ref i 5))
  167. (* (vector-ref x 6) (vector-ref i 6))
  168. (* (vector-ref x 7) (vector-ref i 7))
  169. (* (vector-ref x 8) (vector-ref i 8))
  170. (* (vector-ref x 9) (vector-ref i 9))
  171. (do ((xi
  172. 0
  173. (+
  174. (* (vector-ref x u) (vector-ref i u))
  175. xi))
  176. (u (- w 1) (- u 1)))
  177. ((< u 10) xi))
  178. (vector-ref x w))))))
  179. (lambda (r) (if (< r 10) (vector-ref em r) (it r)))))
  180. (define array:indexer/array
  181. (let ((em
  182. (vector
  183. (lambda (x v i) (+ (vector-ref x 0)))
  184. (lambda (x v i)
  185. (+
  186. (*
  187. (vector-ref x 0)
  188. (vector-ref v (array:actor-index i 0)))
  189. (vector-ref x 1)))
  190. (lambda (x v i)
  191. (+
  192. (*
  193. (vector-ref x 0)
  194. (vector-ref v (array:actor-index i 0)))
  195. (*
  196. (vector-ref x 1)
  197. (vector-ref v (array:actor-index i 1)))
  198. (vector-ref x 2)))
  199. (lambda (x v i)
  200. (+
  201. (*
  202. (vector-ref x 0)
  203. (vector-ref v (array:actor-index i 0)))
  204. (*
  205. (vector-ref x 1)
  206. (vector-ref v (array:actor-index i 1)))
  207. (*
  208. (vector-ref x 2)
  209. (vector-ref v (array:actor-index i 2)))
  210. (vector-ref x 3)))
  211. (lambda (x v i)
  212. (+
  213. (*
  214. (vector-ref x 0)
  215. (vector-ref v (array:actor-index i 0)))
  216. (*
  217. (vector-ref x 1)
  218. (vector-ref v (array:actor-index i 1)))
  219. (*
  220. (vector-ref x 2)
  221. (vector-ref v (array:actor-index i 2)))
  222. (*
  223. (vector-ref x 3)
  224. (vector-ref v (array:actor-index i 3)))
  225. (vector-ref x 4)))
  226. (lambda (x v i)
  227. (+
  228. (*
  229. (vector-ref x 0)
  230. (vector-ref v (array:actor-index i 0)))
  231. (*
  232. (vector-ref x 1)
  233. (vector-ref v (array:actor-index i 1)))
  234. (*
  235. (vector-ref x 2)
  236. (vector-ref v (array:actor-index i 2)))
  237. (*
  238. (vector-ref x 3)
  239. (vector-ref v (array:actor-index i 3)))
  240. (*
  241. (vector-ref x 4)
  242. (vector-ref v (array:actor-index i 4)))
  243. (vector-ref x 5)))
  244. (lambda (x v i)
  245. (+
  246. (*
  247. (vector-ref x 0)
  248. (vector-ref v (array:actor-index i 0)))
  249. (*
  250. (vector-ref x 1)
  251. (vector-ref v (array:actor-index i 1)))
  252. (*
  253. (vector-ref x 2)
  254. (vector-ref v (array:actor-index i 2)))
  255. (*
  256. (vector-ref x 3)
  257. (vector-ref v (array:actor-index i 3)))
  258. (*
  259. (vector-ref x 4)
  260. (vector-ref v (array:actor-index i 4)))
  261. (*
  262. (vector-ref x 5)
  263. (vector-ref v (array:actor-index i 5)))
  264. (vector-ref x 6)))
  265. (lambda (x v i)
  266. (+
  267. (*
  268. (vector-ref x 0)
  269. (vector-ref v (array:actor-index i 0)))
  270. (*
  271. (vector-ref x 1)
  272. (vector-ref v (array:actor-index i 1)))
  273. (*
  274. (vector-ref x 2)
  275. (vector-ref v (array:actor-index i 2)))
  276. (*
  277. (vector-ref x 3)
  278. (vector-ref v (array:actor-index i 3)))
  279. (*
  280. (vector-ref x 4)
  281. (vector-ref v (array:actor-index i 4)))
  282. (*
  283. (vector-ref x 5)
  284. (vector-ref v (array:actor-index i 5)))
  285. (*
  286. (vector-ref x 6)
  287. (vector-ref v (array:actor-index i 6)))
  288. (vector-ref x 7)))
  289. (lambda (x v i)
  290. (+
  291. (*
  292. (vector-ref x 0)
  293. (vector-ref v (array:actor-index i 0)))
  294. (*
  295. (vector-ref x 1)
  296. (vector-ref v (array:actor-index i 1)))
  297. (*
  298. (vector-ref x 2)
  299. (vector-ref v (array:actor-index i 2)))
  300. (*
  301. (vector-ref x 3)
  302. (vector-ref v (array:actor-index i 3)))
  303. (*
  304. (vector-ref x 4)
  305. (vector-ref v (array:actor-index i 4)))
  306. (*
  307. (vector-ref x 5)
  308. (vector-ref v (array:actor-index i 5)))
  309. (*
  310. (vector-ref x 6)
  311. (vector-ref v (array:actor-index i 6)))
  312. (*
  313. (vector-ref x 7)
  314. (vector-ref v (array:actor-index i 7)))
  315. (vector-ref x 8)))
  316. (lambda (x v i)
  317. (+
  318. (*
  319. (vector-ref x 0)
  320. (vector-ref v (array:actor-index i 0)))
  321. (*
  322. (vector-ref x 1)
  323. (vector-ref v (array:actor-index i 1)))
  324. (*
  325. (vector-ref x 2)
  326. (vector-ref v (array:actor-index i 2)))
  327. (*
  328. (vector-ref x 3)
  329. (vector-ref v (array:actor-index i 3)))
  330. (*
  331. (vector-ref x 4)
  332. (vector-ref v (array:actor-index i 4)))
  333. (*
  334. (vector-ref x 5)
  335. (vector-ref v (array:actor-index i 5)))
  336. (*
  337. (vector-ref x 6)
  338. (vector-ref v (array:actor-index i 6)))
  339. (*
  340. (vector-ref x 7)
  341. (vector-ref v (array:actor-index i 7)))
  342. (*
  343. (vector-ref x 8)
  344. (vector-ref v (array:actor-index i 8)))
  345. (vector-ref x 9)))))
  346. (it
  347. (lambda (w)
  348. (lambda (x v i)
  349. (+
  350. (*
  351. (vector-ref x 0)
  352. (vector-ref v (array:actor-index i 0)))
  353. (*
  354. (vector-ref x 1)
  355. (vector-ref v (array:actor-index i 1)))
  356. (*
  357. (vector-ref x 2)
  358. (vector-ref v (array:actor-index i 2)))
  359. (*
  360. (vector-ref x 3)
  361. (vector-ref v (array:actor-index i 3)))
  362. (*
  363. (vector-ref x 4)
  364. (vector-ref v (array:actor-index i 4)))
  365. (*
  366. (vector-ref x 5)
  367. (vector-ref v (array:actor-index i 5)))
  368. (*
  369. (vector-ref x 6)
  370. (vector-ref v (array:actor-index i 6)))
  371. (*
  372. (vector-ref x 7)
  373. (vector-ref v (array:actor-index i 7)))
  374. (*
  375. (vector-ref x 8)
  376. (vector-ref v (array:actor-index i 8)))
  377. (*
  378. (vector-ref x 9)
  379. (vector-ref v (array:actor-index i 9)))
  380. (do ((xi
  381. 0
  382. (+
  383. (*
  384. (vector-ref x u)
  385. (vector-ref
  386. v
  387. (array:actor-index i u)))
  388. xi))
  389. (u (- w 1) (- u 1)))
  390. ((< u 10) xi))
  391. (vector-ref x w))))))
  392. (lambda (r) (if (< r 10) (vector-ref em r) (it r)))))
  393. (define array:applier-to-vector
  394. (let ((em
  395. (vector
  396. (lambda (p v) (p))
  397. (lambda (p v) (p (vector-ref v 0)))
  398. (lambda (p v)
  399. (p (vector-ref v 0) (vector-ref v 1)))
  400. (lambda (p v)
  401. (p
  402. (vector-ref v 0)
  403. (vector-ref v 1)
  404. (vector-ref v 2)))
  405. (lambda (p v)
  406. (p
  407. (vector-ref v 0)
  408. (vector-ref v 1)
  409. (vector-ref v 2)
  410. (vector-ref v 3)))
  411. (lambda (p v)
  412. (p
  413. (vector-ref v 0)
  414. (vector-ref v 1)
  415. (vector-ref v 2)
  416. (vector-ref v 3)
  417. (vector-ref v 4)))
  418. (lambda (p v)
  419. (p
  420. (vector-ref v 0)
  421. (vector-ref v 1)
  422. (vector-ref v 2)
  423. (vector-ref v 3)
  424. (vector-ref v 4)
  425. (vector-ref v 5)))
  426. (lambda (p v)
  427. (p
  428. (vector-ref v 0)
  429. (vector-ref v 1)
  430. (vector-ref v 2)
  431. (vector-ref v 3)
  432. (vector-ref v 4)
  433. (vector-ref v 5)
  434. (vector-ref v 6)))
  435. (lambda (p v)
  436. (p
  437. (vector-ref v 0)
  438. (vector-ref v 1)
  439. (vector-ref v 2)
  440. (vector-ref v 3)
  441. (vector-ref v 4)
  442. (vector-ref v 5)
  443. (vector-ref v 6)
  444. (vector-ref v 7)))
  445. (lambda (p v)
  446. (p
  447. (vector-ref v 0)
  448. (vector-ref v 1)
  449. (vector-ref v 2)
  450. (vector-ref v 3)
  451. (vector-ref v 4)
  452. (vector-ref v 5)
  453. (vector-ref v 6)
  454. (vector-ref v 7)
  455. (vector-ref v 8)))))
  456. (it
  457. (lambda (r)
  458. (lambda (p v)
  459. (apply
  460. p
  461. (vector-ref v 0)
  462. (vector-ref v 1)
  463. (vector-ref v 2)
  464. (vector-ref v 3)
  465. (vector-ref v 4)
  466. (vector-ref v 5)
  467. (vector-ref v 6)
  468. (vector-ref v 7)
  469. (vector-ref v 8)
  470. (vector-ref v 9)
  471. (do ((k r (- k 1))
  472. (r
  473. '()
  474. (cons (vector-ref v (- k 1)) r)))
  475. ((= k 10) r)))))))
  476. (lambda (r) (if (< r 10) (vector-ref em r) (it r)))))
  477. (define array:applier-to-actor
  478. (let ((em
  479. (vector
  480. (lambda (p a) (p))
  481. (lambda (p a) (p (array-ref a 0)))
  482. (lambda (p a)
  483. (p (array-ref a 0) (array-ref a 1)))
  484. (lambda (p a)
  485. (p
  486. (array-ref a 0)
  487. (array-ref a 1)
  488. (array-ref a 2)))
  489. (lambda (p a)
  490. (p
  491. (array-ref a 0)
  492. (array-ref a 1)
  493. (array-ref a 2)
  494. (array-ref a 3)))
  495. (lambda (p a)
  496. (p
  497. (array-ref a 0)
  498. (array-ref a 1)
  499. (array-ref a 2)
  500. (array-ref a 3)
  501. (array-ref a 4)))
  502. (lambda (p a)
  503. (p
  504. (array-ref a 0)
  505. (array-ref a 1)
  506. (array-ref a 2)
  507. (array-ref a 3)
  508. (array-ref a 4)
  509. (array-ref a 5)))
  510. (lambda (p a)
  511. (p
  512. (array-ref a 0)
  513. (array-ref a 1)
  514. (array-ref a 2)
  515. (array-ref a 3)
  516. (array-ref a 4)
  517. (array-ref a 5)
  518. (array-ref a 6)))
  519. (lambda (p a)
  520. (p
  521. (array-ref a 0)
  522. (array-ref a 1)
  523. (array-ref a 2)
  524. (array-ref a 3)
  525. (array-ref a 4)
  526. (array-ref a 5)
  527. (array-ref a 6)
  528. (array-ref a 7)))
  529. (lambda (p a)
  530. (p
  531. (array-ref a 0)
  532. (array-ref a 1)
  533. (array-ref a 2)
  534. (array-ref a 3)
  535. (array-ref a 4)
  536. (array-ref a 5)
  537. (array-ref a 6)
  538. (array-ref a 7)
  539. (array-ref a 8)))))
  540. (it
  541. (lambda (r)
  542. (lambda (p a)
  543. (apply
  544. a
  545. (array-ref a 0)
  546. (array-ref a 1)
  547. (array-ref a 2)
  548. (array-ref a 3)
  549. (array-ref a 4)
  550. (array-ref a 5)
  551. (array-ref a 6)
  552. (array-ref a 7)
  553. (array-ref a 8)
  554. (array-ref a 9)
  555. (do ((k r (- k 1))
  556. (r '() (cons (array-ref a (- k 1)) r)))
  557. ((= k 10) r)))))))
  558. (lambda (r)
  559. "These are high level, hiding implementation at call site."
  560. (if (< r 10) (vector-ref em r) (it r)))))
  561. (define array:applier-to-backing-vector
  562. (let ((em
  563. (vector
  564. (lambda (p ai av) (p))
  565. (lambda (p ai av)
  566. (p (vector-ref av (array:actor-index ai 0))))
  567. (lambda (p ai av)
  568. (p
  569. (vector-ref av (array:actor-index ai 0))
  570. (vector-ref av (array:actor-index ai 1))))
  571. (lambda (p ai av)
  572. (p
  573. (vector-ref av (array:actor-index ai 0))
  574. (vector-ref av (array:actor-index ai 1))
  575. (vector-ref av (array:actor-index ai 2))))
  576. (lambda (p ai av)
  577. (p
  578. (vector-ref av (array:actor-index ai 0))
  579. (vector-ref av (array:actor-index ai 1))
  580. (vector-ref av (array:actor-index ai 2))
  581. (vector-ref av (array:actor-index ai 3))))
  582. (lambda (p ai av)
  583. (p
  584. (vector-ref av (array:actor-index ai 0))
  585. (vector-ref av (array:actor-index ai 1))
  586. (vector-ref av (array:actor-index ai 2))
  587. (vector-ref av (array:actor-index ai 3))
  588. (vector-ref av (array:actor-index ai 4))))
  589. (lambda (p ai av)
  590. (p
  591. (vector-ref av (array:actor-index ai 0))
  592. (vector-ref av (array:actor-index ai 1))
  593. (vector-ref av (array:actor-index ai 2))
  594. (vector-ref av (array:actor-index ai 3))
  595. (vector-ref av (array:actor-index ai 4))
  596. (vector-ref av (array:actor-index ai 5))))
  597. (lambda (p ai av)
  598. (p
  599. (vector-ref av (array:actor-index ai 0))
  600. (vector-ref av (array:actor-index ai 1))
  601. (vector-ref av (array:actor-index ai 2))
  602. (vector-ref av (array:actor-index ai 3))
  603. (vector-ref av (array:actor-index ai 4))
  604. (vector-ref av (array:actor-index ai 5))
  605. (vector-ref av (array:actor-index ai 6))))
  606. (lambda (p ai av)
  607. (p
  608. (vector-ref av (array:actor-index ai 0))
  609. (vector-ref av (array:actor-index ai 1))
  610. (vector-ref av (array:actor-index ai 2))
  611. (vector-ref av (array:actor-index ai 3))
  612. (vector-ref av (array:actor-index ai 4))
  613. (vector-ref av (array:actor-index ai 5))
  614. (vector-ref av (array:actor-index ai 6))
  615. (vector-ref av (array:actor-index ai 7))))
  616. (lambda (p ai av)
  617. (p
  618. (vector-ref av (array:actor-index ai 0))
  619. (vector-ref av (array:actor-index ai 1))
  620. (vector-ref av (array:actor-index ai 2))
  621. (vector-ref av (array:actor-index ai 3))
  622. (vector-ref av (array:actor-index ai 4))
  623. (vector-ref av (array:actor-index ai 5))
  624. (vector-ref av (array:actor-index ai 6))
  625. (vector-ref av (array:actor-index ai 7))
  626. (vector-ref av (array:actor-index ai 8))))))
  627. (it
  628. (lambda (r)
  629. (lambda (p ai av)
  630. (apply
  631. p
  632. (vector-ref av (array:actor-index ai 0))
  633. (vector-ref av (array:actor-index ai 1))
  634. (vector-ref av (array:actor-index ai 2))
  635. (vector-ref av (array:actor-index ai 3))
  636. (vector-ref av (array:actor-index ai 4))
  637. (vector-ref av (array:actor-index ai 5))
  638. (vector-ref av (array:actor-index ai 6))
  639. (vector-ref av (array:actor-index ai 7))
  640. (vector-ref av (array:actor-index ai 8))
  641. (vector-ref av (array:actor-index ai 9))
  642. (do ((k r (- k 1))
  643. (r
  644. '()
  645. (cons
  646. (vector-ref
  647. av
  648. (array:actor-index ai (- k 1)))
  649. r)))
  650. ((= k 10) r)))))))
  651. (lambda (r)
  652. "These are low level, exposing implementation at call site."
  653. (if (< r 10) (vector-ref em r) (it r)))))
  654. (define (array:index/vector r x v)
  655. ((array:indexer/vector r) x v))
  656. (define (array:index/array r x av ai)
  657. ((array:indexer/array r) x av ai))
  658. (define (array:apply-to-vector r p v)
  659. ((array:applier-to-vector r) p v))
  660. (define (array:apply-to-actor r p a)
  661. ((array:applier-to-actor r) p a)))