summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-07-13 21:39:19 -0400
committerrsiddharth <s@ricketyspace.net>2020-07-13 21:40:07 -0400
commitbe0d323f5bbf2dee749358f1c1424f2594900faf (patch)
tree7cb52d8b6305e55ccf68ad25c7e0e03d970290b6
parent30e377d079f35e2c0a617056de9a57b5741f112b (diff)
net: fortytwo.scm: Add adjoin-position
* net/ricketyspace/sicp/two/fortytwo.scm (adjoin-position): New function. Mostly done.
-rw-r--r--net/ricketyspace/sicp/two/fortytwo.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ricketyspace/sicp/two/fortytwo.scm b/net/ricketyspace/sicp/two/fortytwo.scm
index 7ccf00e..e284591 100644
--- a/net/ricketyspace/sicp/two/fortytwo.scm
+++ b/net/ricketyspace/sicp/two/fortytwo.scm
@@ -3,7 +3,8 @@
;;;;
(define-module (net ricketyspace sicp two fortytwo)
- #:export (safe?))
+ #:export (safe?
+ adjoin-position))
(define (accumulate op initial sequence)
(if (null? sequence)
@@ -52,3 +53,8 @@
positions)))
(if (null? in-same-diag) #f #t)))
(not (or (same-row?) (same-diagonal?))))
+
+
+(define (adjoin-position new-row k rest-of-queens)
+ (let ((queen-at-k (cons new-row k)))
+ (append rest-of-queens (list queen-at-k))))