From a65bb9d5857fe23509aabc47e6f624c018fd6c69 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 18 Jun 2023 17:41:09 +0100 Subject: [PATCH] improve file-exists? function --- examples/acquire-delegated-prefix.fnl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/acquire-delegated-prefix.fnl b/examples/acquire-delegated-prefix.fnl index 5f397b3..09dbaa0 100644 --- a/examples/acquire-delegated-prefix.fnl +++ b/examples/acquire-delegated-prefix.fnl @@ -37,10 +37,10 @@ (fn file-exists? [name] - (let [f (io.open name :r)] - (match f - non-nil (or (f:close) true) - (nil err) false))) + (match (io.open name :r) + f (do (f:close) true) + _ false)) + (fn read-line [name] (with-open [f (assert (io.open name :r) (.. "can't open file " name))]