You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Group manipulation wraps code in a function. This is not as complicated as it sounds, but it does entail many steps.
For example, the code:
print("hello world");
print(ellipse(100,100));
will produce two objects on screen: a StringEffect and an EllipseEffect. If the user:
Group-selects both objects, and then
Issues the Group command
the code should be updated to:
fun f1() {
print("hello world");
print(ellipse(100,100));
}
How does this work? Here's a first pass on the algorithm:
The dmGroup manipulation function should take an array es of Effect objects to group.
For each Effect e in es
a. Find parent Node p of e.
b. Recursively find data dependencies of p; let's call these "effect roots" roots.
c. Transitively create a sequence rootseq of roots.
d. Create a funDeff and make rootseq the body.
e. Remove roots from the original AST.
f. Substitute f into program.
g. Append a funApp of f to the end of the program (i.e., create a new seq, put the whole program on the left, and the funApp on the right).
Return the new AST.
eval the new AST.
The output should look exactly the same as the original, but the code will now be function-abstracted.
The text was updated successfully, but these errors were encountered:
Group manipulation wraps code in a function. This is not as complicated as it sounds, but it does entail many steps.
For example, the code:
will produce two objects on screen: a
StringEffect
and anEllipseEffect
. If the user:the code should be updated to:
How does this work? Here's a first pass on the algorithm:
dmGroup
manipulation function should take an arrayes
ofEffect
objects to group.Effect e
ines
a. Find parent
Node p
ofe
.b. Recursively find data dependencies of
p
; let's call these "effect roots"roots
.c. Transitively create a sequence
rootseq
ofroots
.d. Create a
funDef
f
and makerootseq
the body.e. Remove
roots
from the original AST.f. Substitute
f
into program.g. Append a
funApp
off
to the end of the program (i.e., create a newseq
, put the whole program on the left, and thefunApp
on the right).eval
the new AST.The output should look exactly the same as the original, but the code will now be function-abstracted.
The text was updated successfully, but these errors were encountered: