954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help with a version of lisp called drscheme. Writing union function

Here's my code.

(define L ())
(define (union L1 L2)
  ;continue until one list is empty
  (do()
    ((or (null? L1) (null? L2)))
    (cond
      ((<(car L1)(car L2)) (attach(car L1)(cdr L1)L2))
      ((eq?(car L1)(car L2)) (attach(car L1)(cdr L1)(cdr L2)))
      (else(>(car L1)(car L2)) (attach(car L2)L1(cdr L2)))
    )
  )
;after which you continue to add add while one list isn't empty and ;the second one isn't empty. I know I need a new attach function. 
)

(define (attach item List1 List2)
  (cons item L)
  (union List1 List2)
)
lotrsimp12345
Posting Pro in Training
413 posts since Jun 2009
Reputation Points: 47
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You