scheme

Macro stepper in DrRacket

拟墨画扇 提交于 2021-01-27 08:00:49
问题 On the link http://www.ccs.neu.edu/home/ryanc/macro-stepper/tutorial.html there are instructions for working with the macro stepper. However, when I'm going to try it, I can't get the second expansion of myor in the definition of nonzero? function, only the first. Also, I have no buttons "Previous term" and "Next term". So my question is: how i must configure macro stepper to get the second expansion, like in tutorial? 回答1: I'm assuming that your source program looked something like this:

Macro stepper in DrRacket

一笑奈何 提交于 2021-01-27 07:54:50
问题 On the link http://www.ccs.neu.edu/home/ryanc/macro-stepper/tutorial.html there are instructions for working with the macro stepper. However, when I'm going to try it, I can't get the second expansion of myor in the definition of nonzero? function, only the first. Also, I have no buttons "Previous term" and "Next term". So my question is: how i must configure macro stepper to get the second expansion, like in tutorial? 回答1: I'm assuming that your source program looked something like this:

Macro stepper in DrRacket

倖福魔咒の 提交于 2021-01-27 07:52:50
问题 On the link http://www.ccs.neu.edu/home/ryanc/macro-stepper/tutorial.html there are instructions for working with the macro stepper. However, when I'm going to try it, I can't get the second expansion of myor in the definition of nonzero? function, only the first. Also, I have no buttons "Previous term" and "Next term". So my question is: how i must configure macro stepper to get the second expansion, like in tutorial? 回答1: I'm assuming that your source program looked something like this:

Scheme: Remove the maximum from a BST

筅森魡賤 提交于 2021-01-20 12:18:06
问题 Good afternoon everyone, I have very odd question and I'm sorry If I have posted in a wrong part of the forum. I'm trying to understand remove-max function (provided bellow) from a BST written in scheme, but I have a hard time grasping the ideas in it. I know the Scheme syntax, however there is a lot of going on in this function and thus I am a bit confused. (define removemax-BST (lambda (T) (cond ((null? (caddr t)) (cons (cadr t) (car t)) (else (let ((r (removemax-BST (caddr t)))) (cons

Get a subtree by breadth-first index using continuation-passing style

落爺英雄遲暮 提交于 2021-01-04 06:38:07
问题 This question is a follow-up on How do I get a subtree by index?. That question deals with depth-first indexing (for which I have provided a depth-first continuation-passing style solution). This question here is about breadth-first indexing, and specifically about solving the problem using continuation-passing style (CPS). Suppose I have a tree that represents '(+ (* 5 6) (sqrt 3)) : The index of nodes starts from 0 at the root, and is breadth-first. In the picture above, I have labelled all

Get a subtree by breadth-first index using continuation-passing style

 ̄綄美尐妖づ 提交于 2021-01-04 06:37:10
问题 This question is a follow-up on How do I get a subtree by index?. That question deals with depth-first indexing (for which I have provided a depth-first continuation-passing style solution). This question here is about breadth-first indexing, and specifically about solving the problem using continuation-passing style (CPS). Suppose I have a tree that represents '(+ (* 5 6) (sqrt 3)) : The index of nodes starts from 0 at the root, and is breadth-first. In the picture above, I have labelled all

Powerset of a list using abstract list functions

£可爱£侵袭症+ 提交于 2021-01-04 05:51:25
问题 Is it possible to make a racket function to return powerset of a given list ? Constraints- without explicit recursion use abstract list functions code contained in 2 lines (actual requirement) For eg: (powerset '(1 2)) '((1 2) (1) (2) ()) in any order. The other question I found still uses explicit recursion. My workflow: Taking (powerset '(a b c)) as an example, First get a list of whole numbers up to (expt 2 (length list)) ;'(0 1 2 3 4 5 6 7) Convert them into their respective binary form 2

How do I replace part of a tree with another tree at the specified index?

帅比萌擦擦* 提交于 2021-01-04 05:42:38
问题 Suppose I have two trees: Tree A — '(+ (* 5 6) (sqrt 3)) : Tree B — '(- 4 2) : Goal: replace one of tree A's subtrees with tree B at a specified tree A index position. The index position starts at 0 at the root node and is depth-first. In the figure for tree A above, I have labelled all the nodes with their index to show this. For example, (replace-subtree treeA 4 treeB) replaces the subtree at index 4 in tree A with tree B, resulting in the tree (+ (* 5 6) (- 4 2)) : How do I implement

How do I replace part of a tree with another tree at the specified index?

不问归期 提交于 2021-01-04 05:42:05
问题 Suppose I have two trees: Tree A — '(+ (* 5 6) (sqrt 3)) : Tree B — '(- 4 2) : Goal: replace one of tree A's subtrees with tree B at a specified tree A index position. The index position starts at 0 at the root node and is depth-first. In the figure for tree A above, I have labelled all the nodes with their index to show this. For example, (replace-subtree treeA 4 treeB) replaces the subtree at index 4 in tree A with tree B, resulting in the tree (+ (* 5 6) (- 4 2)) : How do I implement

Generating powerset in one function, no explicit recursion, and using only simplest primitives in Racket

北城余情 提交于 2021-01-04 02:10:01
问题 Note: this is a bonus for homework, but I have spent way too long on trying things to no avail. Help is much appreciated, but not necessary I suppose. Premise: generate a powerset for a list of numbers, but without using any helpers, explicit recursion, looping, or functions/constants other than cons , first , rest , empty? , empty , else , lambda , and cond , while using only one define on the language level Intermediate Student with Lambda . The order of the powerset does not matter. What I