;; -*-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)))))
