racket

filling a list with a series of known elements

只愿长相守 提交于 2020-08-10 03:37:58
问题 Is there a quicker way to write the following code? (list var1 var2 var3 var4 var5 ... var100) Basically all the elements are variables with prefix "var". 回答1: You can do this with a macro: #lang racket (require syntax/parse/define (for-syntax racket/syntax)) (define-simple-macro (varN-range var:id arg:number ...) #:with [varN ...] (for/list ([N (apply in-range (syntax->datum #'(arg ...)))]) (format-id #'var "~a~a" #'var N)) (list varN ...)) Using it: > (define var1 "a") > (define var2 "b") >

When should I use Rosette's shallow vs. deep embedding for program synthesis?

人盡茶涼 提交于 2020-07-18 11:44:17
问题 Some tutorials for Rosette introduce program synthesis using shallow embedding and others using deep embedding. After reading Torlak et Bodik's "Growing Solver-Aided Languages with ROSETTE", it seems the shallow embedding is good for fast prototyping (since it does not require defining DSL & interpreter) and the deep embedding is good for making queries with stronger correctness guarantees. Is this a good rule of thumb for deciding which embedding to use? What are good reasons for using

When should I use Rosette's shallow vs. deep embedding for program synthesis?

牧云@^-^@ 提交于 2020-07-18 11:44:16
问题 Some tutorials for Rosette introduce program synthesis using shallow embedding and others using deep embedding. After reading Torlak et Bodik's "Growing Solver-Aided Languages with ROSETTE", it seems the shallow embedding is good for fast prototyping (since it does not require defining DSL & interpreter) and the deep embedding is good for making queries with stronger correctness guarantees. Is this a good rule of thumb for deciding which embedding to use? What are good reasons for using