Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If God had intended Man to program, we'd be born with serial I/O ports.


devel / comp.lang.lisp / .Re: Alternatives 4

SubjectAuthor
o .Re: Alternatives 4Robert L.

1
.Re: Alternatives 4

<t13af1$1bb8$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16982&group=comp.lang.lisp#16982

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!vBtjmgw8d33gtod2lZwILA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: Alternatives 4
Date: Sat, 19 Mar 2022 01:08:52 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t13af1$1bb8$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="44392"; posting-host="vBtjmgw8d33gtod2lZwILA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Sat, 19 Mar 2022 01:08 UTC

From Paul Graham's "On Lisp".

(defun before (x y lst &key (test #'eql))
(and lst
(let ((first (car lst)))
(cond ((funcall test y first) nil)
((funcall test x first) lst)
(t (before x y (cdr lst) :test test))))))

If x is found in lst before y, return the tail starting with x.

Scheme:

(define (before x y lst compare)
(let ((r (member x lst
(lambda (a b) (or (compare x b) (compare y b))))))
(and r (not (compare y (car r))) r)))

(before 4 5 '(0 5 2 4 5 8 9) =)
===>
#f

(before 4 5 '(0 2 4 5 8 9) =)
===>
(4 5 8 9)

(before 4 4 '(0 2 4 5 8 9) =)
===>
#f

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor