[racket] Question

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Sep 5 14:29:11 EDT 2012

#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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120905/96c8381a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120905/96c8381a/attachment.p7s>

Posted on the users mailing list.