loop doesn't work properly in scheme

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

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.





So in the case where the elements are equal =, then the loop is finished? It will terminate at least. What does convert do? If argument is a vector why does the parameter name indicate that it is a list?
– Sylwester
7 hours ago



=


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.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Trying to Print Gridster Items to PDF without overlapping contents