Question: This is a code written in Dr Racket. Why it uses cons and what cons does? ; contract: insert: l ( list of numbers )

This is a code written in Dr Racket. Why it uses cons and what cons does?
; contract: insert: l(list of numbers) val(number) list of numbers
; test
; function
(define (insert 1val (cond ((empty? l)(list val))
(( val (first l))(cons val l)) ; insert it to the list
(else (cons (first l)(insert (rest l) val))); do not insert the value, but
add first of 1 not to remove element from the list
)
 This is a code written in Dr Racket. Why it uses

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!