On Sun, Jul 23, 2017 at 7:30 PM, Zelphir Kaltstahl <zelphirkaltst...@gmail.com> wrote: > > How can I make my code more efficient, without changing the basic logic of it? >
In addition to what I wrote before, there are a couple of places where you're constructing new lists when you don't need to. In `gini-index`, for example, you don't actually need the intermediate lists that you're summing over. You can instead use `for*/sum` and make the whole thing a lot simpler and more efficient: (define (gini-index subsets class-labels label-column-index) (for*/sum ([subset (in-list subsets)] [class-label (in-list class-labels)]) (calc-proportion subset class-label label-column-index))) (This is under the assumption that you've changed your data representation to a list, which you really should.) And you can make a similar simplification to `calc-proportion`. -- 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.