Hello,
I got a problem to code something with 'loop'.
Basically, I am trying to insert following codes into 'loop',
however, it seems difficult to me.
;------
(if (= (aref arr i) 1)
(cond ((zerop (aref arr (- i 1)) 1)
(count i))
((= (aref arr (- i 1)) 1)
(if (> (- (aref arr1 i) (aref arr1 (- i 1))) 1)
(count i)
nil))))
;---------------------
How can I convert the above codes into 'loop'?
I tried to use 'if' and 'when', but it doesn't work.
For example,
(setf my-num (loop for i from 1 to (- ver-num 2)
when (= (aref vertices-for-polygon i) 1)
when (zerop (aref vertices-for-polygon (- i 1)))
count i
; error here.-> else (= (aref vertices-for-polygon (- i 1)) 1)
when (> (- (aref index-number i)
(aref index-number (- i 1))) 1)
count i))
Thanks,
Sungwoo
Sorry, I just solve the problem as
(setf my-num (loop for i from 1 to (- ver-num 2)
when (= (aref vertices-for-polygon i) 1)
when (zerop (aref vertices-for-polygon (- i 1)))
count i
else
when (> (- (aref index-number i)
(aref index-number (- i 1))) 1)
count i))
Thanks,
Sungwoo
In article <················@naggum.net>, Erik Naggum <····@naggum.net>
wrote:
> * "Sungwoo, Lim" <·······@cad.strath.ac.uk>
> > I tried to use 'if' and 'when', but it doesn't work.
>
> Stylistically, when should not take an else branch.
>
> #:Erik
Thanks, =)
Sungwoo