Ok then, i got problem with this. I wrote a procedure which i called 
'make-mutable-selector', which make a mutable selector from quote symbol 
like 'mcaar, 'mcadr etc. But i don't know, how i can use this in the code, 
what i want to write... i mean a macro with-mcxrs.

(define-macro make-mutable-selector   
  (lambda (new-selector)
    (let ((loop (gensym)))
      `(lambda (pair)
         (let ,loop ((mutable-selector ,new-selector)
                     (number 2))
           (begin
           (if (equal? (car (string->list (substring (symbol->string 
mutable-selector) number))) #\r)
               (begin
                 pair)
               (cond ((equal? (car (string->list (substring (symbol->string 
mutable-selector) number))) #\a)(begin (mcar (,loop mutable-selector (+ 1 
number)))))
                     ((equal? (car (string->list (substring (symbol->string 
mutable-selector) number))) #\d)(begin (mcdr (,loop mutable-selector (+ 1 
number)))))
                     (else "Error")))))))))
                   
((make-mutable-selector 'mcaar) (mcons (mcons 1 2) '()))    ;= 1
((make-mutable-selector 'mcdar) (mcons (mcons 1 2) '()))    ;= 2

... etc

(define-macro with-mcxrs
  (lambda body
 
    (let ((loop (gensym)))
      `(let ,loop ((selectors (quote ,@body)) ) ;;list of selectors
          (if (null? selectors)
              (,@body)
              (let ((new-selector (car selectors)))
                                  (begin (make-mutable-selector (quote 
(string->list
                                                                 (substring 
(car new-selector) 2
                                                                            
(- (string-length (car new-selector))1)) )) ,@body))))))))


I don't know, how i can fix this. Please help me.
Patrik
Dne čtvrtek 10. května 2018 5:04:05 UTC+2 David K. Storrs napsal(a):
>
> Hi Patrik, 
>
> From what I've seen, people on this list generally don't help with 
> homework assignments, especially not when the request is simply 
> "please do this for me" as opposed to "please help me figure out this 
> one piece that I'm stuck on".  You'd probably get better answers if 
> you specified: 
>
> - Specifically what you don't understand 
> - What you've tried 
> - What happened and what the error messages were 
>
>
>
> On Wed, May 9, 2018 at 6:56 PM, Patrik novak <high...@seznam.cz 
> <javascript:>> wrote: 
> > Hello, 
> > i got really big problem. I study at university for a second year. We 
> > programming at scheme, (not racket) and i have two hard quest for exams 
> at 
> > scheme. My life depends on it. So i please you to help me. 
> > 
> > First: 
> > 
> > (with-mcxrs 
> >  (let ((a (mcons (mcons 1 2) (mcons (mcons 3 4) '())))) 
> >    (list (mcaar a) 
> > (mcdar a) 
> > (mcaadr a) 
> > (mcdadr a)))) 
> > 
> > --> by using define-macro NOT DEFINE-SYNTAX and we HAVE TO use this 
> > procedure for it: 
> > symbol?, string-upcase, symbol->string, string-length, string-ref, 
> > string->list, substring 
> > 
> > I know, that were an article about this problem (i think, joah martin 
> wrote 
> > that), but answers are useless for me :/ how i said, i need it in 
> > define-macro by using this small procedures, at school we dont know what 
> is 
> > "syntax-parse" for example. 
> > 
> > Second: 
> > 
> > (define test 
> >   (make-generator 
> >    (lambda (collect) 
> >      (collect 10) 
> >      (collect 20) 
> >      (collect 30)))) 
> > 
> > (list (test) (test) (test) (test)) ;; => (10 20 30 #<void>) 
> > 
> > (define test2 
> >   (make-generator 
> >    (lambda (collect) 
> >      (let x () 
> >        (collect (random 100)) 
> >        (x))))) ..   ...this piece of code has to work also. 
> > 
> > Quest: Implement a procedure "Make-generator" one argument, which is 
> > procedure one argument, which we called a generated procedure and 
> evaluation 
> > will we called "collect procedure". Result of aplication is procedure 
> > without argument, which we called "a generator". The generator caused 
> the 
> > generator to apply a procedure that once applied to a brightening 
> procedure 
> > with some the argument will switch back to the place where it was 
> applied 
> > generator and its result is that argument. For another application the 
> > generator switches the context into the generating procedure in the 
> place 
> > where the pre-treatment procedure has been applied, etc. Once you have 
> > generate the procedure ends without applying the brightening procedure, 
> the 
> > result the application of the generator is then an undefined value. 
> > 
> > So please, help me, quickly ! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to racket-users...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to