fix factorial example
This commit is contained in:
parent
7b6d18bc6a
commit
4a89ccd5d1
3 changed files with 8 additions and 5 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.editor.unknown {
|
.editor.unknown {
|
||||||
border: 1px dashed dodgerblue;
|
/* border: 1px dashed dodgerblue;
|
||||||
display: inline-block;
|
display: inline-block; */
|
||||||
}
|
}
|
||||||
.editor.error, .editor.unknown.error {
|
.editor.error, .editor.unknown.error {
|
||||||
border: 1px solid red;
|
border: 1px solid red;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { useEffect, useRef, type ReactNode, type KeyboardEvent, useState } from "react";
|
import { useEffect, useRef, type ReactNode, type KeyboardEvent, useState } from "react";
|
||||||
|
|
||||||
import "./Input.css";
|
|
||||||
import { focusPrevElement, focusNextElement, setRightMostCaretPosition } from "../../util/dom_trickery";
|
import { focusPrevElement, focusNextElement, setRightMostCaretPosition } from "../../util/dom_trickery";
|
||||||
|
|
||||||
|
import "./Input.css";
|
||||||
|
|
||||||
interface InputProps {
|
interface InputProps {
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
text: string;
|
text: string;
|
||||||
|
|
|
||||||
|
|
@ -107,19 +107,21 @@ export function deepEvalCall(s: CallBlockState, env: DynamicEnvironment): DeepEv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function deepEvalLet(s: LetInBlockState, env: DynamicEnvironment): DeepEvalResultLet {
|
export function deepEvalLet(s: LetInBlockState, env: DynamicEnvironment): DeepEvalResultLet {
|
||||||
|
let valueResult;
|
||||||
const valueEnv = {
|
const valueEnv = {
|
||||||
names: trie.insert(env.names)(s.name)({
|
names: trie.insert(env.names)(s.name)({
|
||||||
|
// dirty: we introduce indirection to enable recursion
|
||||||
recursive: true,
|
recursive: true,
|
||||||
i: () => {
|
i: () => {
|
||||||
try {
|
try {
|
||||||
return { val: valueResult.val };
|
return valueResult;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { err: e };
|
return { err: e };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
const valueResult = deepEvalExpr(s.value, valueEnv);
|
valueResult = deepEvalExpr(s.value, valueEnv);
|
||||||
const innerEnv = {
|
const innerEnv = {
|
||||||
names: trie.insert(env.names)(s.name)({i: valueResult.val}),
|
names: trie.insert(env.names)(s.name)({i: valueResult.val}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue