End position of recursion

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
ehhc
Posts: 4
Joined: Sun Nov 25, 2018 11:52 am

End position of recursion

Post by ehhc »

Hey guys,
I'm new to CFA and i have a question: Can i figure out the end position of a recursion? I mean:
If i have the following:

Code: Select all

startshape START
rule START{
 REC {y -1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x -0.1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x 0.1}
}
and i want to add a circle at the top of the stack.. how can i get the position of it?
Is there a way? Since the stack/path alsways ends somewhere different, i cannot simply draw the circle at a static position...

Thank you :)

User avatar
MtnViewJohn
Site Admin
Posts: 875
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: End position of recursion

Post by MtnViewJohn »

You can't know where shape REC will end from within shape START. All you can do if have shape REC have a recursion termination rule that draws the circle.

Code: Select all

startshape START
rule START{
 REC {y -1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x -0.1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x 0.1}
}
rule REC 0.05 {
  CIRCLE {s 0.1 a -0.5}
}

ehhc
Posts: 4
Joined: Sun Nov 25, 2018 11:52 am

Re: End position of recursion

Post by ehhc »

Sad to hear that :(
But thanks a lot for your answer :)

Post Reply