From 73a4bfc3d8e9bb5365e33a11a6ad3b8340d5195b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 12 Jun 2022 21:09:35 +0200 Subject: Remove custom let*. While it was nice, the most important part was the multi-valued let from srfi-71 (which is implemented in srfi-71)). The minor pattern matching structures could often be replaced with car+cdr, or a propper match. --- module/hnh/util/graph.scm | 3 ++- module/hnh/util/path.scm | 21 +++++++++++---------- module/hnh/util/tree.scm | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'module/hnh/util') diff --git a/module/hnh/util/graph.scm b/module/hnh/util/graph.scm index 03c2ae3c..01e9a63a 100644 --- a/module/hnh/util/graph.scm +++ b/module/hnh/util/graph.scm @@ -7,6 +7,7 @@ (define-module (hnh util graph) :use-module (hnh util) :use-module (srfi srfi-1) + :use-module (srfi srfi-71) :use-module (srfi srfi-9 gnu)) ;; Immutable directed graph @@ -88,7 +89,7 @@ (let loop ((graph graph)) (if (graph-empty? graph) '() - (let* ((node graph* (find-and-remove-node-without-dependencies graph))) + (let ((node graph* (find-and-remove-node-without-dependencies graph))) (cons node (loop graph*)))))) (lambda (err caller fmt args data) (car graph)))) diff --git a/module/hnh/util/path.scm b/module/hnh/util/path.scm index 7eac630b..340c2d8b 100644 --- a/module/hnh/util/path.scm +++ b/module/hnh/util/path.scm @@ -1,5 +1,6 @@ (define-module (hnh util path) :use-module (srfi srfi-1) + :use-module (srfi srfi-71) :use-module (hnh util)) (define // file-name-separator-string) @@ -40,16 +41,16 @@ ;; ⇒ ("" "usr" "lib" "test") ;; @end example (define-public (path-split path) - (let* ((head tail - (car+cdr - (reverse - (map reverse-list->string - (fold (lambda (c done) - (if (/? c) - (cons '() done) - (cons (cons c (car done)) (cdr done)))) - '(()) - (string->list path))))))) + (let ((head tail + (car+cdr + (reverse + (map reverse-list->string + (fold (lambda (c done) + (if (/? c) + (cons '() done) + (cons (cons c (car done)) (cdr done)))) + '(()) + (string->list path))))))) (cons head (remove string-null? tail)))) diff --git a/module/hnh/util/tree.scm b/module/hnh/util/tree.scm index 95328b5f..34e10365 100644 --- a/module/hnh/util/tree.scm +++ b/module/hnh/util/tree.scm @@ -1,5 +1,6 @@ (define-module (hnh util tree) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-71) #:use-module (hnh util) #:export (make-tree left-subtree right-subtree @@ -13,8 +14,8 @@ ;; both it's children equal to @var{null}. (define (make-tree pred? lst) (unless (null? lst) - (let* ((head tail (partition (lambda (el) (pred? (car lst) el)) - (cdr lst)))) + (let ((head tail (partition (lambda (el) (pred? (car lst) el)) + (cdr lst)))) (list (car lst) (make-tree pred? head) (make-tree pred? tail))))) -- cgit v1.2.3