#lang racket

(require rackunit)

;; [List X Y Z] -> [List Z Y X]
;; switch items one and three in a 3-element list 

(module+ test 
  (check-equal? (switch-one-and-three1 '(a b c)) '(c b a))
  (check-equal? (switch-one-and-three1 '(1 2 3)) '(3 2 1)))

(define (switch-one-and-three1 ls)
  (match ls
    [`(,one ,two ,three) `(,three ,two ,one)]))

That's 50$ -- Matthias


On Sep 5, 2012, at 2:26 PM, Ashley Fowler wrote:

> Can anybody help me with this problem? I have an idea but would like some 
> suggestions on how to start. The problem is below...
> 
> Write a procedure (switch-one-and-three1 LS) that takes a list of 
> exactly three items as its argument and returns the list with the first
> and third items switched around. You may assume the input list contains 
> exactly three items
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to