mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 06:09:17 +02:00
62 lines
1.6 KiB
Scheme
62 lines
1.6 KiB
Scheme
(define *version* "0.0.1 (Pre-release)")
|
|
|
|
(define *version-banner*
|
|
(string-append "
|
|
:@
|
|
@@@
|
|
@@@@:
|
|
`@@@@@+
|
|
.@@@+@@@ Cyclone
|
|
@@ @@ An experimental Scheme compiler
|
|
,@ https://github.com/justinethier/cyclone
|
|
'@
|
|
.@
|
|
@@ #@ (c) 2014 Justin Ethier
|
|
`@@@#@@@. Version " *version* "
|
|
#@@@@@
|
|
+@@@+
|
|
@@#
|
|
`@.
|
|
|
|
"))
|
|
|
|
(define *c-file-header-comment*
|
|
(string-append "/**
|
|
** This file was automatically generated by the Cyclone scheme compiler
|
|
**
|
|
** (c) 2014 Justin Ethier
|
|
** Version " *version* "
|
|
**
|
|
**/
|
|
"))
|
|
|
|
;; Features implemented by this Scheme
|
|
(define *features* '(cyclone))
|
|
|
|
;; Based off corresponding SRFI-1 definition
|
|
(define (delete x lis)
|
|
(filter (lambda (y) (not (equal? x y))) lis))
|
|
|
|
;; Inefficient version based off code from SRFI-1
|
|
(define (delete-duplicates lis)
|
|
(define (recur lis) ; ((lis lis))
|
|
(if (null? lis) lis
|
|
(let* ((x (car lis))
|
|
(tail (cdr lis))
|
|
(new-tail (recur (delete x tail))))
|
|
(if (eq? tail new-tail) lis (cons x new-tail)))))
|
|
(recur lis))
|
|
|
|
;; Insert obj at index k of list, increasing length of list by one.
|
|
(define (list-insert-at! lis obj k)
|
|
(cond
|
|
((null? lis) (error "list-insert-at!, lis cannot be null"))
|
|
((and (> k 0) (null? (cdr lis)))
|
|
(set-cdr! lis (cons obj '())))
|
|
((zero? k)
|
|
(let ((old-car (car lis)))
|
|
(set-car! lis obj)
|
|
(set-cdr! lis (cons old-car (cdr lis)))))
|
|
(else
|
|
(list-insert-at! (cdr lis) obj (- k 1)))))
|
|
|