equiv - 1. 1 ;; Examples: (my-weird-fun 1 2 3) => 6 ;;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname equiv) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; Ru Wang 20319247 CS135 Sect 001 Tut 108 ; ;;Question 2: ; ;;my-weird-fun: number expression expression -> number ; ;;purpose: to create a functionally equivalent function as weird-fun from question
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1. 1 ;; Examples: (my-weird-fun 1 2 3) => 6 ;; (my-weird-fun 'symbol 'symbol 'symbol) => 0 ;; (my-weird-fun 2 3 'symbol) => Error: as "+" cannot add symbols. ; ;; Definition: (define (my-weird-fun a b c) (cond [(symbol? b) 0] [else (cond [(symbol? c) 0] [else (+ a b c)])])) ;;Tests: (check-expect(my-weird-fun 1 2 3)6) (check-expect(my-weird-fun 'symbol 'symbol 'symbol)0) (check-expect(my-weird-fun 2 3 'symbol) 0)...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.

Ask a homework question - tutors are online