Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Scheme/DrRacket

Name: Anonymous 2013-01-28 0:26

How the fuck do I do this?

Writethefunctionmatch-pointsthatconsumestwofunctions(fun1andfun2, each of which consumes one value) and one list (lst). The function match-points produces a list of boolean values which has the same length as lst. The first value in the produced list will be true if the functions agree (i.e., have the same value) when they are applied on the first element of the provided list, and false
otherwise. The second value in the produced list will be true if the functions produce the same value when they are applied on the second element in the provided list, and so on. For example,

(match-points sqr (lambda (x) (+ x x)) (list 0 2 -2))
=> (list true true false)

since 0+0=02 and 2+2=22, but -2+(-2)=-4 which is not equal to (-2)2=4.

Name: Anonymous 2013-01-28 0:35

(define (sqr x)
  (* x x))

(define (dubs x)
  (+ x x))

(define (match-points f g lst)
  (map (lambda (x)
         (= (f x) (g x)))
       lst))

(match-points sqr dubs '(0 2 -2))

Name: Anonymous 2013-01-28 1:42

: sqr dup * ;
: dubs dup + ;
: match
  0 do
    dup sqr swap dubs
    = if ." y " else ." n " then
  loop ;
0 2 -2 3 match

Name: >>3 2013-01-28 1:54

Just read the first few chapters of starting-forth and that thing came out.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List