vicuna-13b· LMSYS
Arena Human Preference 55K
Can you write a quicksort in scheme?
- User
Can you write a quicksort in scheme?
- Assistant
Sure! Here is a simple implementation of quicksort in Scheme:
code(define (quicksort lst) (if (null? lst) '() (let* ((mid (nth lst 0))) (let* ((l (filter #t (<= mid 0))) (r (filter #t (>= mid 0))))) (if (null? l) r (let* ((q (nth l 0))) (if (<= q mid) (let* ((temp (nth l 1))) (cons q (quicksort (filter #t (< q mid)) l))) (cons mid (quicksort (filter #t (<= mid q)) r)))))))))This implementation uses the same basic structure as the implementation in Python, but the syntax is slightly different due to the different language. In particular, the statement is written using the macro, and the and forms are used to define nested bindings.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.