File: define-higher-order.sps

package info (click to toggle)
chez-srfi 0.0%2Bgit20241031.b424440%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,608 kB
  • sloc: lisp: 25,299; sh: 326; makefile: 11
file content (29 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
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
#!r6rs
;; Copyright 2021 Lassi Kortela
;; SPDX-License-Identifier: MIT

(import (except (rnrs) define) (srfi :64 testing) (srfi :219))

(test-begin "srfi-219")

(let ()
  (define ((greet-with-prefix prefix) suffix)
    (string-append prefix " " suffix))
  (let ((greet (greet-with-prefix "Hello")))
    (test-equal "Hello there!" (greet "there!"))))

(let ()
  (define ((append-to . a) . b)
    (apply append (append a b)))
  (test-equal '()
    ((append-to '()) '()))
  (test-equal '(1 2 3 4 5 6 7 8)
    ((append-to '(1 2) '(3 4)) '(5 6) '(7 8))))

(let ()
  (define (((jenga a b) c d))
    (list a b c d))
  (test-equal '(1 2 3 4)
    (((jenga 1 2) 3 4))))

(test-end)