1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
;; -*-theme-*-
;; Copyright (C) 2014, 2021 Tommi Höynälänmaa
;; Distributed under GNU Lesser General Public License version 3,
;; see file doc/LGPL-3.
(define-body (examples list-as-sequence)
(import (standard-library list-utilities))
(define-param-virtual-method sequence-ref (%element)
(((seq (:list-as-sequence %element)) (index <integer>))
%element pure)
(uniform-list-ref (field-ref seq 'contents) index))
(define-param-virtual-method sequence-length (%element)
(((seq (:list-as-sequence %element))) <integer> pure)
(length (field-ref seq 'contents)))
(define-param-virtual-method sequence-map (%source %target)
(((proc (:procedure (%source) %target pure))
(seq (:list-as-sequence %source)))
(:list-as-sequence %target) pure)
(create (:list-as-sequence %target)
(map proc (field-ref seq 'contents)))))
|