Skip to content

Commit 7398493

Browse files
committed
Include SRFI 161. Update documentation.
1 parent a1ab835 commit 7398493

File tree

4 files changed

+108
-2
lines changed

4 files changed

+108
-2
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Changelog
22

3-
## 1.5.2 (2018-09-10)
3+
## 1.5.2 (2018-09-16)
44
- Several substantial extensions of library `(lispkit draw)`
5+
- Support for turtle graphics via library `(lispkit draw turtle)`
6+
- New example code showcasing `(lispkit draw turtle)` features
7+
- New SRFI library: SRFI 161
58

69
## 1.5.1 (2018-08-19)
710
- Bugfixes and name changes in `(lispkit draw)`

LispKit.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
CC1AAE3B1CC3CF0F00D1806F /* LispKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCAD52BA1C48403800DBD8EE /* LispKit.framework */; };
3030
CC1AAE3C1CC3CF0F00D1806F /* LispKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CCAD52BA1C48403800DBD8EE /* LispKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3131
CC1EA5C9214E6CD8006BBE7E /* Turtle.scm in Copy examples */ = {isa = PBXBuildFile; fileRef = CC1EA5C8214E6BF3006BBE7E /* Turtle.scm */; };
32+
CC1EA5CB214EF30E006BBE7E /* 161.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CC1EA5CA214EEF41006BBE7E /* 161.sld */; };
3233
CC201A6D1DBD72C100045A4D /* LibraryRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC201A6C1DBD72C100045A4D /* LibraryRegistry.swift */; };
3334
CC2345411F655BD800C38817 /* datatype.sld in Copy pre-installed LispKit libraries */ = {isa = PBXBuildFile; fileRef = CC2345401F655B8B00C38817 /* datatype.sld */; };
3435
CC2345431F655C0A00C38817 /* Datatypes.scm in Resources */ = {isa = PBXBuildFile; fileRef = CC2345421F655C0A00C38817 /* Datatypes.scm */; };
@@ -399,6 +400,7 @@
399400
dstPath = LispKit/Resources/Libraries/srfi;
400401
dstSubfolderSpec = 7;
401402
files = (
403+
CC1EA5CB214EF30E006BBE7E /* 161.sld in Copy pre-installed SRFI libraries */,
402404
CC26264020F8014900AC08E8 /* 113.sld in Copy pre-installed SRFI libraries */,
403405
CC26263E20F5707800AC08E8 /* 112.sld in Copy pre-installed SRFI libraries */,
404406
CC26263C20F56E9F00AC08E8 /* 111.sld in Copy pre-installed SRFI libraries */,
@@ -458,6 +460,7 @@
458460
CC14F4AF1F939486000FB1E0 /* Features.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Features.swift; sourceTree = "<group>"; };
459461
CC14F4B11F93A455000FB1E0 /* FeatureRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureRequirement.swift; sourceTree = "<group>"; };
460462
CC1EA5C8214E6BF3006BBE7E /* Turtle.scm */ = {isa = PBXFileReference; lastKnownFileType = text; path = Turtle.scm; sourceTree = "<group>"; };
463+
CC1EA5CA214EEF41006BBE7E /* 161.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = 161.sld; sourceTree = "<group>"; };
461464
CC201A6C1DBD72C100045A4D /* LibraryRegistry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryRegistry.swift; sourceTree = "<group>"; };
462465
CC2345401F655B8B00C38817 /* datatype.sld */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = datatype.sld; sourceTree = "<group>"; };
463466
CC2345421F655C0A00C38817 /* Datatypes.scm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Datatypes.scm; sourceTree = "<group>"; };
@@ -832,6 +835,7 @@
832835
CC96D10420386860006AA27B /* 151.sld */,
833836
CC0AEFF71F522A7500119BF6 /* 152.sld */,
834837
CCEEF3901FAF3F70006C4581 /* 158.sld */,
838+
CC1EA5CA214EEF41006BBE7E /* 161.sld */,
835839
);
836840
path = srfi;
837841
sourceTree = "<group>";

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ _LispKit_ provides support for the following core features, many of which are ba
5959
`(lispkit object)`, `(lispkit enum)`,
6060
`(lispkit logic)`, `(lispkit iteration)`, `(lispkit set)`, `(lispkit stack)`, `(lispkit queue)`,
6161
`(lispkit heap)`, `(lispkit wt-tree)`, `(lispkit prettify)`, `(lispkit json)`,
62-
[`(lispkit draw)`](https://github.com/objecthub/swift-lispkit/wiki/LispKit-Draw),
62+
[`(lispkit draw)`](https://github.com/objecthub/swift-lispkit/wiki/LispKit-Draw), `(lispkit draw turtle)`,
6363
and `(lispkit pdf)`
6464

6565
_LispKit_ is incompatible or incomplete with respect to the following R7RS features:
@@ -101,6 +101,7 @@ framework:
101101
- [SRFI 151: Bitwise Operations](https://srfi.schemers.org/srfi-151/srfi-151.html)
102102
- [SRFI 152: String Library](https://srfi.schemers.org/srfi-152/srfi-152.html)
103103
- [SRFI 158: Generators and Accumulators](https://srfi.schemers.org/srfi-158/srfi-158.html)
104+
- [SRFI 161: Unifiable Boxes](https://srfi.schemers.org/srfi-161/srfi-161.html)
104105

105106

106107
## Architecture
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
;;; SRFI 161
2+
;;; Unifiable Boxes
3+
;;;
4+
;;; Unifiable boxes are, like the boxes of SRFI 111, objects with a single mutable state.
5+
;;; A constructor, predicate, accessor, and mutator are provided.
6+
;;; In addition to the state, an equality predicate and union operations (link, union, unify)
7+
;;; are provided. Applying a union operation to two unifiable boxes makes the two boxes equal
8+
;;; (in the sense of the equality predicate). As a consequence, their state will also become
9+
;;; identical. In the case of link and union, it will be the state of one of the two unioned
10+
;;; boxes. In the case of unify, the state is determined by a supplied unification procedure.
11+
;;;
12+
;;; Copyright (C) Marc Nieper-Wißkirchen (2018). All Rights Reserved.
13+
;;;
14+
;;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
15+
;;; software and associated documentation files (the "Software"), to deal in the Software
16+
;;; without restriction, including without limitation the rights to use, copy, modify, merge,
17+
;;; publish, distribute, sublicense, and/or sell copies of the Software, and to permit
18+
;;; persons to whom the Software is furnished to do so, subject to the following conditions:
19+
;;;
20+
;;; The above copyright notice and this permission notice shall be included in all copies or
21+
;;; substantial portions of the Software.
22+
;;;
23+
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24+
;;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25+
;;; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26+
;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27+
;;; CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
28+
;;; OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29+
;;;
30+
;;; LispKit Port:
31+
;;; Copyright © 2018 Matthias Zenger. All rights reserved.
32+
33+
(define-library (srfi 161)
34+
35+
(export ubox
36+
ubox?
37+
ubox-ref
38+
ubox-set!
39+
ubox=?
40+
ubox-unify!
41+
ubox-union!
42+
ubox-link!)
43+
44+
(import (lispkit base))
45+
46+
(begin
47+
(define-record-type <ubox>
48+
(make-ubox parent rank value)
49+
ubox?
50+
(parent ubox-parent ubox-set-parent!)
51+
(rank ubox-rank ubox-set-rank!)
52+
(value ubox-value ubox-set-value!))
53+
54+
(define (ubox-find ubox)
55+
(let ((parent (ubox-parent ubox)))
56+
(if parent
57+
(let ((root (ubox-find parent)))
58+
(ubox-set-parent! ubox root)
59+
root)
60+
ubox)))
61+
62+
(define (ubox value)
63+
(make-ubox #f 0 value))
64+
65+
(define (ubox-ref ubox)
66+
(ubox-value (ubox-find ubox)))
67+
68+
(define (ubox-set! ubox val)
69+
(ubox-set-value! (ubox-find ubox) val))
70+
71+
(define (ubox=? ubox1 ubox2)
72+
(eq? (ubox-find ubox1) (ubox-find ubox2)))
73+
74+
(define (ubox-unify! proc ubox1 ubox2)
75+
(let ((value (proc (ubox-ref ubox1) (ubox-ref ubox2))))
76+
(ubox-union! ubox1 ubox2)
77+
(ubox-set! ubox1 value)))
78+
79+
(define (ubox-union! ubox1 ubox2)
80+
(let ((root1 (ubox-find ubox1))
81+
(root2 (ubox-find ubox2)))
82+
(unless (eq? root1 root2)
83+
(cond ((< (ubox-rank root1) (ubox-rank root2))
84+
(ubox-set-parent! root1 root2)
85+
(ubox-set-value! root1 #f)
86+
(ubox-set-rank! root1 #f))
87+
(else
88+
(when (= (ubox-rank root1) (ubox-rank root2))
89+
(ubox-set-rank! root1 (+ (ubox-rank root1) 1)))
90+
(ubox-set-parent! root2 root1)
91+
(ubox-set-value! root2 #f)
92+
(ubox-set-rank! root2 #f))))))
93+
94+
(define (ubox-link! ubox1 ubox2)
95+
(ubox-unify! (lambda (x y) y) ubox1 ubox2))
96+
)
97+
)
98+

0 commit comments

Comments
 (0)