Scheme initial impression

xiaoxiao2021-03-06  41

Scheme This variant of the Lisp language is more interesting. The Scheme version I use is DrSCHEME 2.09, and the interface is relatively beautiful. You can download at http://www.plt-scheme.org/.

Let me feel that the scheme is the process of expression. It uses a way to "prefix expression", but also write a large parent-parenthef. For example, 3 5, you must write ( 3 5) in Scheme, where " " and numbers must have a space. I think this may be the mode of "function type language". Scheme The " " as a function, the function of this function is to calculate the sum of two parameters. In principle, " " functions can only have two parameters, but there is actually a simple writing method. For example, a connection: 3 5 2 1 can be replaced with only one " ", writing: ( 3 5 2 1)

There is no concept of op amp in Scheme, because it is a function! So only use (). The Scheme interpreter calculates from the most inside, until the outermost layer, resulting in the result. For example, calculate 3 5 * 3 to write ( 3 (* 5 3)).

Scheme's function definition is also very special, such as defining a function S = 3.1416 * r * r of a calculated circular area, can be written: (Define (S R) (* 3.1416 r r)))

When R = 5, call the function S: (s 5)

In the same program, the function can be called multiple layers, such as calculating an area of ​​a ring: (set the inner diameter R, outer diameter R). S-ring = S outside -s, the function in the corresponding scheme is: (Area Out IN) ((s ince))

转载请注明原文地址:https://www.9cbs.com/read-68786.html

New Post(0)