Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Love may fail, but courtesy will previal." -- A Kurt Vonnegut fan


devel / comp.lang.lisp / Lisp problem to solve

SubjectAuthor
o Lisp problem to solveRobert L.

1
Lisp problem to solve

<sucj7v$1peh$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!j3gMQKcTBPbPhesBtuDbWw.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: Lisp problem to solve
Date: Mon, 14 Feb 2022 03:45:04 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sucj7v$1peh$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="58833"; posting-host="j3gMQKcTBPbPhesBtuDbWw.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. - Mon, 14 Feb 2022 03:45 UTC

John Thingstad wrote:

> Pn++ Tue, 20 Nov 2007 23:59:24 +0100, skrev Mark Tarver
> <dr.mtarver@ukonline.co.uk>:
>
> > On 20 Nov, 14:48, ryan.dufra...@gmail.com wrote:
> >> You are given a list of transactions along with the
> >> profits from the transactions. Write code that will return the
> >> transaction with the maximum profit. If many transactions have the
> >> same and maximusm profit, the code can return any of these. For
> >> example,
> >> given ((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)), the code should.
> >> return T3.
> >>
> >> I am looking for code or pseudocode.
> >
> > (SETQ *LIST* '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))
> >
> > Shortest solution is 1 line.
> >
> > (FIRST (FIRST (SORT *LIST* (FUNCTION (LAMBDA (X Y) (> (SECOND X)
> > (SECOND Y)))))))
> >
> > Mark
> >
>
> or (caar (sort *list* #'> :key #'second))

Gauche Scheme:

(define List '((T1 20) (T2 88) (T3 188) (T4 99) (T5 66)))

(define (max-trans a b) (if (> (cadr b) (cadr a)) b a))

;; Without sorting.
(car (reduce max-trans #f List))

===>
T3


devel / comp.lang.lisp / Lisp problem to solve

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor