Initial impressions of Scheme

Source: Internet
Author: User

Scheme is an interesting variant of the lisp language. The scheme version I used is drscheme 2.09. The interface is pretty nice. Can be downloaded in http://www.plt-scheme.org.

 

What makes me feel uncomfortable is scheme's processing of expressions. It uses a method similar to "prefix expression" and also writes a lot of parentheses. For example, to compute 3 + 5, scheme must be written as (+ 3 5). There must be a space between "+" and a number. I think this may be the "functional language" model. Scheme regards "+" as a function, which is used to calculate the sum of two parameters. In principle, the "+" function can have only two parameters, but there is still a simple method. For example, a join method:
3 + 5 + 2 + 1
It can be replaced by only one "+". Writing:
(+ 3 5 2 1)

There is no concept of computing priority in scheme, because they are all functions! Therefore, you can only use (). The scheme interpreter calculates the result from the beginning to the outermost layer. For example, to compute 3 + 5*3, you must write it as (+ 3 (* 5 3 )).

Scheme functions are also very special. For example, to define a function S = 3.1416 * r for calculating the circular area, you can write it as follows:
(Define (s r)
(* 3.1416 R ))

When r = 5, call function s:
(S 5)

In the sameProgramThe function can be called at multiple levels, such as calculating the area of a ring: (set the inner diameter to R and the outer diameter to R ). Within s-s, the corresponding scheme function is:
(Define (area out in)
(-(S out) (s in )))

 

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.