Note that there are some explanatory texts on larger screens.

plurals
  1. POWrite Scheme data structures so they can be eval-d back in, or alternative
    primarykey
    data
    text
    <p>I'm writing an application (A <a href="http://github.com/jmillikan/Yet-Another-Juggling-Animator" rel="nofollow noreferrer">juggling pattern animator</a>) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will <strong>let me "explode" expressions into expressions that can still be eval'd but contain the data as literals</strong> for manual tweaking. </p> <p>For example,</p> <pre><code>(4hss-&gt;sexp "747") </code></pre> <p>is a function call that generates a legitimate pattern. If I eval and print that, it becomes </p> <pre><code>(((7 3) - - -) (- - (4 2) -) (- (7 2) - -) (- - - (7 1)) ((4 0) - - -) (- - (7 0) -) (- (7 2) - -) (- - - (4 3)) ((7 3) - - -) (- - (7 0) -) (- (4 1) - -) (- - - (7 1))) </code></pre> <p>which can be "read" as a string, but will not "eval" the same as the function. For this statement, of course, what I need would be as simple as</p> <pre><code>(quote (((7 3... </code></pre> <p>but other examples are non-trivial. This one, for example, contains structs which print as vectors:</p> <pre><code>pair-of-jugglers ; --&gt; (#(struct:hand #(struct:position -0.35 2.0 1.0) #(struct:position -0.6 2.05 1.1) 1.832595714594046) #(struct:hand #(struct:position 0.35 2.0 1.0) #(struct:position 0.6 2.0500000000000003 1.1) 1.308996938995747) #(struct:hand #(struct:position 0.35 -2.0 1.0) #(struct:position 0.6 -2.05 1.1) -1.3089969389957472) #(struct:hand #(struct:position -0.35 -2.0 1.0) #(struct:position -0.6 -2.05 1.1) -1.8325957145940461)) </code></pre> <p>I've thought of at least three possible solutions, none of which I like very much.</p> <p>Help me out before I start having bad recursion dreams again.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload