On Sat, Aug 12, 2017 at 6:21 AM, Zelphir Kaltstahl <zelphirkaltst...@gmail.com> wrote: > > ~~~ > (define (gini-index subsets label-column-index) > (for*/list ([subset (in-list subsets)] > [label (in-list (list 0 1))]) > (place pch > (place-channel-put pch (list subset label label-column-index)) > (let ([data (place-channel-get pch)]) > (calc-proportion (first data) > (second data) > (third data)))))) > ~~~ > > The `subset` inside `(place-channel-put pch (list subset label > label-column-index))` gets underlined and the error is: > > subset: identifier used out of context
Two things: First, regarding the above code, if you look at the docs for `place`, you'll see: "The `body`s close only over `id` plus the *top-level* bindings of the enclosing module..." [emphasis added]. You're trying to treat `subset`, `label`, and `label-column-index` as if they were in the new place's closure, but those bindings are all local, so they're not available. In the Rosetta example you cited, `numbers` is explicitly sent (via a `place-channel-put`) from the main place to the newly created one. You'd need to do the same. Second, though, you don't want to do this. Creating a place is expensive enough that creating several each time you compute a gini coefficient will probably make your code run very slowly. You mention that you tried to use a place more than once. That's a better approach. (Apparently, you had some trouble with that approach, but yes, it can be done.) However, you should try using futures instead of places. They're less expensive to create and generally best suited for numeric tasks like yours (as the Guide says -- and you should definitely read the section of the Guide on parallelism [http://docs.racket-lang.org/guide/parallelism.html]. - Jon -- 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.