[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Utkarsh Singh] Undefined simultaneous definitions

From: Utkarsh Singh
Subject: [Utkarsh Singh] Undefined simultaneous definitions
Date: Mon, 20 Sep 2021 09:46:43 +0530

Note: Resending because previous message doesn't appears in archive.

-------------------- Start of forwarded message --------------------
From: Utkarsh Singh <>
Subject: Undefined simultaneous definitions
Date: Mon, 20 Sep 2021 08:45:48 +0530

Hi Guilers,

First of all I would like to thank you for maintaining this wonderful
programming language.

SICP Section 4.3 defines a non-deterministic (or ambiguous) evaluator
which helps in non-deterministic computing.  In implementing such an
evaluator I am having difficulty in defining `letrec' special form and
procedure definition with simultaneous internal definition.  For
example, consider the following REPL session:

;;; Amb-Eval input:
(define (findout32 x)
  (letrec ((even?
            (lambda (n)
              (if (= n 0)
                (odd? (- n 1)))))
            (lambda (n)
              (if (= n 0)
                (even? (- n 1))))))
     ((even? x) 20)
     ((odd? x) 30)
     (else 40))))

;;; Starting a new problem 
;;; Amb-Eval value:

;;; Amb-Eval input:
(findout32 10)

;;; Starting a new problem ERROR: In procedure scm-error:
Unassigned variable -- LOOKUP-VARIABLE-VALUE odd?

I tried to debug this issue using `trace' command and it seems that my
evaluator is *not* correctly evaluating sequence of `set!' expression
generated by `scan-out-defines' (see source file for definition).

For now I am going to attach the following files in order to
sufficiently explain the problem:

1. ambeval.scm (Implementation of evaluator)
2. test-ambeval.scm (Test suite for evaluator)
3. test-letrec.log (Erroneous log generated by test suite for `letrec')

Thank you,
Utkarsh Singh

Utkarsh Singh

Attachment: ambeval.scm
Description: Evaluator

Attachment: ambeval-test.scm
Description: Test suite

Attachment: test-letrec.log
Description: Letrec log

-------------------- End of forwarded message --------------------

Utkarsh Singh

reply via email to

[Prev in Thread] Current Thread [Next in Thread]