# Need help translating some scheme: exception error: function set/2 undefined

**URL:** <https://erlangforums.com/t/need-help-translating-some-scheme-exception-error-function-set-2-undefined/1099>\
**Category:** LFE Questions\
**Tags:** lfe-questions\
**Created:** [February 19, 2022, 2:22pm UTC](https://erlangforums.com/t/need-help-translating-some-scheme-exception-error-function-set-2-undefined/1099 "2022-02-19T14:22:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge](https://erlangforums.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@Jorge](https://erlangforums.com/u/Jorge)\
**Post date:** [February 19, 2022, 2:22pm UTC](https://erlangforums.com/t/need-help-translating-some-scheme-exception-error-function-set-2-undefined/1099/1 "2022-02-19T14:22:32Z")

</div>

Im trying to translate some scheme examples in LFE and i stuck in that piece of code. someone can give me a tip?

```erlang
lfe> (defun class-box (init-value)
       (let ((content init-value))
         (lambda (msg)
           (let ((m (car msg)))
             (cond
               ((== m 'read) content)
               ((== m 'write!)
                (set content (cadr msg))
                 content)))))))
                 
lfe> (set box-1 (class-box 50))
#Fun<lfe_eval.30.123855323/1>

lfe> (funcall box-1 '(read))                  
50
       
lfe> (funcall box-1 '(write! 56))         
** exception error: function set/2 undefined

```

---

<div class="post-metadata">

**Author:** ![mdbergmann](https://erlangforums.com/user_avatar/erlangforums.com/mdbergmann/32/1243_2.png) [@mdbergmann](https://erlangforums.com/u/mdbergmann)\
**Post date:** [February 19, 2022, 7:32pm UTC](https://erlangforums.com/t/need-help-translating-some-scheme-exception-error-function-set-2-undefined/1099/2 "2022-02-19T19:32:30Z")

</div>

Since LFE (as is Erlang) is immutable and fully functional you can’t reassign `content` using `set`.  
The way `content` is stored here in the ‘let over lambda’ is not doable in Erlang/LFE because of immutability. Erlang/LFE is completely immutable. The `content` variable here represents state, which in Erlang/LFE is handled in a process.
