algorithm - Scheme How To Return Multiple Values? -


I've noticed that almost all scheme jobs can be returned only as a list output.

In the following, I would like to return many values ​​of all adjacent nodes of the neighbors.

  (defined neighbor LW) (if (and (= 1l) (= 1w)) (list (and (L (+ 1W)) (and (+ 1l) W)))); How to output 2 or more values? In this case, I am testing for the first time if the node is in the corner, if so, then return 2 values ​​of coordinates where (L and W + 1), (L + 1 and W)) Basically if I (1, 1) return me (1,2) (1,2) and (2,1)  

apply only when the edge of the node Has only one neighbor, in this case I have 3 values ​​

When there is no increase, then I will have 4 returns. I

I tried opposition, attachment , Su I do not want to work with any of the additional values. I need a sub-function. How should I implement it so that I can pass the return value and return all the adjacent nodes Can I reuse it for?

Edit : I got the answer: The keyword " value " to return multiple values ​​Example:

  (Define LW) (value (write L) (write w) (newline) (list (+ 1w) l) (list w (+ 1 l)))  

Value, continuity style, and there are at least three modes of multiple layers in the list Values:

  (Import (RNR)); Let-values ​​+ value (define (foo1) (value 1 2 3) (two-value ((BB) (FUI))) (list of display (BC)) (Newline)); CPS (Define Foo2K) (F1) (FU2 (Lambda (ABC)) (List of Performance (BC)) (Newline); List (Define (FU3) (List) 1 2 3) (come (results (foo3)) (display result) (newline))  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -