From: ·······@cad.strath.ac.uk
Subject: Q: looking for simplified version of this code.
Date:
Message-ID: <91vsqr$bv6$1@nnrp1.deja.com>
Merry Christmas to all~!
Before take a nice holiday, could anyone help me solve this problem?
Below code works, but looks little bit odd.
Is there anyways to make this code more simple?
Thanks for your help. =)
Sungwoo
;--------------------------------------
(setf first-max (if (zerop (length copy-array))
0
(aref copy-array 0))
second-max (if (< (length copy-array) 2)
0
(aref copy-array 1))
third-max (if (< (length copy-array) 3)
0
(aref copy-array 2))
fourth-max (if (< (length copy-array) 4)
0
(aref copy-array 3)))
Sent via Deja.com
http://www.deja.com/
From: SRS
Subject: Re: Q: looking for simplified version of this code.
Date:
Message-ID: <9206gs$ka3$1@nnrp1.deja.com>
In article <············@nnrp1.deja.com>,
·······@cad.strath.ac.uk wrote:
> Merry Christmas to all~!
>
> Before take a nice holiday, could anyone help me solve this problem?
> Below code works, but looks little bit odd.
> Is there anyways to make this code more simple?
> Thanks for your help. =)
>
> Sungwoo
>
> ;--------------------------------------
> (setf first-max (if (zerop (length copy-array))
> 0
> (aref copy-array 0))
> second-max (if (< (length copy-array) 2)
> 0
> (aref copy-array 1))
> third-max (if (< (length copy-array) 3)
> 0
> (aref copy-array 2))
> fourth-max (if (< (length copy-array) 4)
> 0
> (aref copy-array 3)))
>
> Sent via Deja.com
> http://www.deja.com/
>
Well, you could use a vector instead of four distinct variables:
(setf max-vector (make-array 4 :initial-element 0))
(replace max-vector copy-array)
-- SRS
Sent via Deja.com
http://www.deja.com/
From: ·······@cad.strath.ac.uk
Subject: Re: Q: looking for simplified version of this code.
Date:
Message-ID: <920ch1$phk$1@nnrp1.deja.com>
> Well, you could use a vector instead of four distinct variables:
>
> (setf max-vector (make-array 4 :initial-element 0))
> (replace max-vector copy-array :end1 (length copy-array))
>
Thanks, =)
Sungwoo
Sent via Deja.com
http://www.deja.com/