How does β€œlet” work on the Scheme?

I use letto create a temporary variable, and then use this temporary variable in the following statement. However, DrScheme complained

let: bad syntax (not an identifier and expression for a binding) in: temp

This is my piece of code:

(define (case-one-helper str)
  (let (temp (substring str (+ 3 (string-contains str "my"))))
    (substring temp (string-contains temp " "))))

I wonder if you need to know the value of a variable created with let, in compound time?

Edit I just realized I missed it ().

Thank,

+5
source share
2 answers

, , , , let " " , , , , .

:

(let ((a (list 1 2 3))
      (b (list 4 5 6)))
     (cons a b))

:

((lambda (list-a list-b) (cons list-a list-b)) (list 1 2 3) (list 4 5 6))

, - , , ( ... let* -, , ).

+9

let :

(define (case-one-helper str)
  (let ((temp (substring str (+ 3 (string-contains str "my")))))
    (substring temp (string-contains temp " "))))
+4

All Articles