Are Scheme functions one liners? -


I am following the structure and lecture of computer programs and attempt to resolve the earlier 1.3 I am the first to try as the following code:

  (define (sumsq abc) ((define the highest (if (> (if (> ab) ab) (If (& gt; ac) ac () (if (> gt; ab) () (if (> gt; ac) (if (> gt; ac)) (second (and (& Gt; if (> AB) (BA (> (>) CA)) (+ (* Highest Highest) (* seconds_H SECOND_H)))  

I was not working and I raised the solution and defined it by using the technique defined at this point

 ; ex 1.3 ;;) (define (class x (* Xx) (define (sum of - square xy) (+ (square x) (square y)) (define (largest-two-three xyz) (if (> = xy) ( The class of yoga is x (if (> = yz)) (the squares of the sum y (if (> = xz) xz)))  

The difference was that Define the variable i was using multiple state And then the classes to yoga, while the right way to define my every line as the function

How do you plan to work in a liner? Or did not I miss the whole thing?

What you have written (decrease an additional scale):

  (define (sumsq abc) (if ( & Gt; AC)) (if (> AC) (if (> (> (> (> (> (> () () () () () () (if (& gt; Gt; AB) (if (> AB) BA (if (>) is CA))) (+ (* Highest Highest) (* seconds_H SECOND_H))  

Their solutions do different intersections and homogeneous sections in different forests, but I do not think that what is important is written (+ (* AA) (* BB)) will to stop you from calculating two values, which will let you write a function is finally a big expression, but now there are big things to worry about.

It seems that the problem you are experiencing is that your (if ...) expressions are too big to understand easily. Note that there are two patterns which are displayed several times: (if (> (gt ; A) A) and (if (> a b) b) . And minimal work, so they are useful to define them:

  (define (minimum AB) (if (& lt;  

In this way, you can rewrite your solution:

  (defined by sumsq Define the highest (if (& gt; (maximum AB) (maximum AC)) (maximum AB) (max AC)) (second (H) (if (> (minimum AB) Define it (reducing the minimum AB) (+ (* highest highest) (* seconds_H seconds_H)))  

it again:

  (define (sumsq abc) (define maximum Define TAM (maximum AB) (max AC)) (second_h (maximum (minimum AB) (minimum AC)) (+ (* highest highest)) (* seconds_H seconds_H)))  

Note how easy it is to write, it is more pronounced to argue with (maximum (maximum) (max.)) obviously the maximum a B and c , and in fact it can be rewritten in the form of (max (maximum AB)) . second_h Seeing, however, it It is not clear that this is correct. What will happen when a is the smallest of three values?

The tricks they use in their solutions, they first compare x and y . If x & lt; Y , then you know that y is not the smallest of the three, so it is either the highest or the second highest number. The other numbers you want to use are the highest x and z , because the lower part of them will be the smallest of the three, which you want to ignore. The same logic applies when y .


Comments