Op 6-4-2012 9:20, Danny Yoo schreef:


On Friday, April 6, 2012, Roelof Wobben wrote:

    Op 5-4-2012 20:29, Danny Yoo schreef:

            I start with this :

            aaaaa|


        Concretely, what does the editor world value look like at this
        point?
        You're representing the state somewhat ambiguously.  Can you
        represent
        the above in terms of (make-editor ... ...)?



    Yes, (make-editor  aaaaaa    a  """)


This can't be, as make-editor can only take two strings. The structure definition of make editor is:

    (define-struct editor (pre post))

Where both pre and post are both strings.

            now someone press 3 times the left key.
            So I have  aa/aaa


    rep has he value of aaaaa
    s has the value of a
    t has also the value of a.



You make the same conceptual mistake here. This representation does not fit the shape of the structure definition.


Go back and make sure you understand the data definition. If you have questions about it, please feel free to ask.


Oke,
Back to the beginning.

In the text is noted.
(define-struct <http://docs.racket-lang.org/htdp-langs/beginner.html#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._define-struct%29%29>editor(prepost))
;Editor= (make-editorStringString)
;interp. (make-editorst)means the text in the editor is
;(string-append <http://docs.racket-lang.org/htdp-langs/beginner.html#%28def._%28lib._htdp-beginner..rkt._lang%29._%28%28lib._lang%2Fhtdp-beginner..rkt%29._string-append%29%29>st)with the cursor displayed between sand t



So for aaaaaaa| s has the value of aaaaa en t has the value of ""
For aaaa|aaaa s  I think s has the value of aaaaa and t has the value of aaa

I have a idea.
If I use the length of the first string and I press one time on the left-key then the new-length could be the old-one - 1. Then I could use substring to cut that part away. The t part I could say if it's empty substring ( s , (string-lenght s), 1) and if it's not empty use a string-append.

Am I on the right track ?

Roelof

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to