Skip to content

Commit 3ff1934

Browse files
Fix: Add pipelines type.
1 parent 9481617 commit 3ff1934

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

demo/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const WASM_SOURCES = DEV
1313
? [`https://demo.edgepython.com/compiler_lib.wasm${_bust}`]
1414
: [`./compiler_lib.wasm${_bust}`];
1515

16-
const DEFAULT_CODE = `"""\nImplements a pure functional pipeline using head-tail recursion to avoid state mutation.\n\nReferences:\n* Backus, J. (1978). Algebra of Programs (Function composition).\n"""\n\ndef double(n: int) -> int:\n return n * 2\n\ndef square(n: int) -> int:\n return n * n\n\ndef apply_pipeline(value: int, steps: list[int]) -> int:\n # Stop recursion when no steps remain\n if not steps:\n return value\n\n first_fn = steps[0]\n remaining_steps = steps[1:]\n\n return apply_pipeline(first_fn(value), remaining_steps)\n\ndef transform_list(elements: list[int], steps: list[int]) -> list[int]:\n # Stop recursion when list is empty\n if not elements:\n return []\n\n head = elements[0]\n tail = elements[1:]\n\n transformed = apply_pipeline(head, steps)\n\n return [transformed] + transform_list(tail, steps)\n\ndata: list[int] = [1, 2, 3]\npipeline: list[int] = [double, square]\n\nresult = transform_list(data, pipeline)\n\nprint(f"Input: {data}")\nprint(f"Output: {result}")`;
16+
const DEFAULT_CODE = `"""\nImplements a pure functional pipeline using head-tail recursion to avoid state mutation.\n\nReferences:\n* Backus, J. (1978). Algebra of Programs (Function composition).\n"""\n\ndef double(n: int) -> int:\n return n * 2\n\ndef square(n: int) -> int:\n return n * n\n\ndef apply_pipeline(value: int, steps: list[int]) -> int:\n # Stop recursion when no steps remain\n if not steps:\n return value\n\n first_fn = steps[0]\n remaining_steps = steps[1:]\n\n return apply_pipeline(first_fn(value), remaining_steps)\n\ndef transform_list(elements: list[int], steps: list[int]) -> list[int]:\n # Stop recursion when list is empty\n if not elements:\n return []\n\n head = elements[0]\n tail = elements[1:]\n\n transformed = apply_pipeline(head, steps)\n\n return [transformed] + transform_list(tail, steps)\n\ndata: list[int] = [1, 2, 3]\npipeline: list = [double, square]\n\nresult = transform_list(data, pipeline)\n\nprint(f"Input: {data}")\nprint(f"Output: {result}")`;
1717

1818
const CLS = { ok: 'ml-auto text-[#7daf7a]', err: 'ml-auto text-[#d67f6d]' };
1919
const MAX_LINES = 99;

0 commit comments

Comments
 (0)