Scheme 如何在每次迭代中保存新文件
我想在宏代码的每次迭代中创建一个新文件 我试图在文件名中输入一个count变量,但它的解释与变量不同Scheme 如何在每次迭代中保存新文件,scheme,Scheme,我想在宏代码的每次迭代中创建一个新文件 我试图在文件名中输入一个count变量,但它的解释与变量不同 (define xStart -10 ) (define xFinish 10 ) (define xIncrement 8 ) (define yStart -10 ) (define yFinish 10 ) (define yIncrement 8 ) (define count 0 ) (do ( (xValue xStart (+ xValue xIncrement ) )
(define xStart -10 )
(define xFinish 10 )
(define xIncrement 8 )
(define yStart -10 )
(define yFinish 10 )
(define yIncrement 8 )
(define count 0 )
(do ( (xValue xStart (+ xValue xIncrement ) ) )
( (> xValue xFinish ) xValue )
(do ( (yValue yStart (+ yValue yIncrement ) ) )
( (> yValue yFinish ) yValue )
(+ count 1)
(edit:move (entity:get-by-name "source") xValue yValue -50)
(raytrace:all-sources)
(edit:select (cadr (entity:faces (entity:get-by-name "Block 1"))))
(analysis:irradiance)
(analysis:irradiance-save "Z:/shadow/maps/.txt")
(analysis:irradiance-close)
(display: count)
)
)
该函数将数字转换为字符串。函数会附加字符串
(analysis:irradiance-save (string-append "Z:/shadow/maps/"
(number->string count)
".txt"))
但是(+count1)
什么也不做。您必须将count
设置为新值
(set! count (+ count 1))
宏在哪里?宏是代码转换,所以它是抽象语法。如果您希望它处理运行时绑定而不是代码,那么可能应该将其设置为过程。我试试看。