> On Jun 1, 2017, at 12:25 AM, Neil Van Dyke <n...@neilvandyke.org> wrote: > > Steve Byan's Lists wrote on 05/31/2017 10:05 PM: >> I'd appreciate a short example of what you mean by using `apply` and >> `lambda` to destructure the list. > > I'll babble more than you want here, in case anyone on the list is curious in > general... > > #lang racket/base > > (define (do-something-with-pmem-drain-record thread-id start-time > elapsed-time result) > (log-debug "DRAIN RESULT ~S" result)) > > (define (do-something-with-pmem-flush-record thread-id start-time > elapsed-time result addr length) > (log-debug "FLUSH RESULT ~S" result)) > > (define (do-something-with-record record) > (case (car record) > ((pmem_drain) (apply do-something-with-pmem-drain-record > (cdr record))) > ((pmem_flush) (apply do-something-with-pmem-flush-record > (cdr record))) > (else (error 'do-something-with-record > "invalid record ~S" > record)))) > > (define example-input > (open-input-string "(pmem_drain 140339047277632 923983542378153 83 0)")) > > (do-something-with-record (read example-input)) > > That's just one way to do it that's rapid to write initially, maintainable, > and (possibly) very efficient at runtime.
Thanks, I understand the idea. It looks promising. Best regards, -Steve -- Steve Byan steveb...@me.com Littleton, MA -- 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.