2010-01-20-higher-order-functions

2010-01-20-higher-order-functions - )) ;; bad codding style...

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 2010-01-20-higher-order- functions) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) (define (has-zero lst) (if (null? lst) false (or (= (first lst) 0) (has-zero (rest lst)))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: )) ;; bad codding style - you may forget to either replace 0 to 1, or "has-zero" to "has-one", so it may recurse to different function #|(define (has-one lst) (if (null? lst) false (or (= (first lst) 1) (has-one (rest lst))) )) |# | ; lets write a new function "has", and parametrize it (define (has num lst) (if (null? lst) false (or (= (first lst) num) (has num (rest lst))) )) (define (has-one lst) (has 1 lst))...
View Full Document

Ask a homework question - tutors are online