loop doesn't work properly in scheme
Clash Royale CLAN TAG#URR8PPP
convert just changes to list to vector and condition = p 0 will terminate the process
– 이재찬
1 hour ago
loop doesn't work properly in scheme
So
(let loop ((p (- (length lst) 1)) (i 0) (l lst))
(cond
((= p 0) lst)
((= i p) (loop (+ p -1) 0 l))
((> (vector-ref (convert lst) i) (vector-ref (convert lst) p)) (loop (+ p 0) (+ i 1) (swap (convert l) i p)))
((< (vector-ref (convert lst) i) (vector-ref (convert lst) p)) (loop (+ p 0) (+ i 1) l))
)
it will return original state on (= p 0) when i send lst of '#(3 2 1) but when i run swap function separately it will return '#(1 2 3). p is the last array and i is the first of the array.
=
convert
convert just changes to list to vector and condition = p 0 will terminate the process
– 이재찬
1 hour ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
So in the case where the elements are equal
=
, then the loop is finished? It will terminate at least. What doesconvert
do? If argument is a vector why does the parameter name indicate that it is a list?– Sylwester
7 hours ago