SICP1.3 MIT (CLT) scheme implementation (LISP)

Source: Internet
Author: User



The function required by the topic requires the following three things to be done:

    1. Write a function that accepts three numbers as a parameter
    2. Determine the larger of the three numbers in two
    3. Calculates the sum of squares of a larger two numbers (the sum of the squares of two numbers)

We're going to do these three tasks from the back to the next step.

CSDN No Lisp. It's tagged with python.

#lang racket;; SICP 1.3;;  Try 1 (define (square x) (* x x)) (define (sum x y) (+ (square x) (square y))) (define (sum-largest x y z) (  cond (= (min x y z) x (sum y z)) ((        = (min x y z) (sum x z)) ((= (min x y z)) (sum x y)))        ; Try 2 (define (Largest-three x y z) (  if (>= x y) (      sum x (if (>= y z) y z))      (Sum y (if (>= x z) x z))) ;; Testing 1 (sum-largest 2 3 6) (Sum-largest 5 8 12); Testing 2 (Largest-three 4 8 75)

SICP1.3 MIT (CLT) scheme implementation (LISP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.