I am not entirely sure this answer is what you are looking for, but the
following generator
will produce the pairs of the list instead of the elements.

(define (in-pairs xs)
  (make-do-sequence
   (λ ()
     (define (pos->element p) p)
     (define (next-position p) (cdr p))
     (define initial-position xs)
     (define (continue-with-pos? p) (pair? p))
     (values pos->element
             next-position
             initial-position
             continue-with-pos?
             #f #f))))

Example:

>* (for ([p (in-pairs '(1 2 3 4))])
*    (displayln p))
(1 2 3 4)
(2 3 4)
(3 4)
(4)

So you can use

(define descriptions (list "this" "that"))
(define amounts      (list 4467.61 2428.37))
(for ([d descriptions] [ds (in-pairs descriptions)])
      [a amounts]      [as (in-pairs amounts])
   ...)

And use ds and as to get to other descriptions/amounts than the current
(which are in d and a).

/Jens Axel



Den fre. 14. jun. 2019 kl. 16.45 skrev Sanjeev Sharma <throw...@gmail.com>:

> within this for loop is there any way to access different pieces of the
> description and amt?  car-ing and cdr-ing for example?
>
> Or move the identifier definitions into the let*, and pass those to for in
> some way?
>
> (let*((ratio 9/12))
>   (for((description(list "this" "that"))
>        (amt(list 4467.61 2428.37)))
>     (printf"~a ~a: changed values\n"
>            description
>            (cat(* amt ratio) -2.))))
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/07ad5ce3-0ba8-48a5-a356-5cb1545de4cd%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/07ad5ce3-0ba8-48a5-a356-5cb1545de4cd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
-- 
Jens Axel Søgaard

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABefVgzj7eyxCpoq%3D3ULbeZ9-BsDkPj50RZa%3D-nhQxnf65u4rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to