我想做这样的事:
* Define some functions
#+begin_src python :noweb_ref defs
def f1(a,b,c):
return True
def f2(d,e,f):
return False
#+end_src
* Use them in a results-exported block later
#+begin_src python :results output :exports both :tangle yes
<<defs>>
print "test results:"
print f1(1,2,3)
#end_src我想要发生的是,当对块进行评估以生成导出输出时,<>将被扩展为缠结式。实际发生的情况是,<>按字面计算,并导致语法错误。
当将像这样的块缠绕到输出文件中时,一切都很完美,但是当我导出缓冲区时,我想不出如何做同样的事情。
有什么建议吗?
发布于 2013-03-18 19:55:56
我不确定能不能真正理解你的观点。但
1)您错过了一个noweb:yes头参数
2)您可以使用<<func()>>插入计算func的结果(而不是func的代码) --在这里,我不确定您到底想要什么。
发布于 2013-05-28 12:49:30
您也可以使用:noweb no-export。这显示了导出文件中的noweb语法,但在计算或缠绕文件时扩展了代码块。
如果您只想展示一个算法,那么:noweb strip-export是很棒的:
<<prep>>
result = A + B
<<plot>>然后导出的文件显示如下:
result = A + Bhttps://stackoverflow.com/questions/15484091
复制相似问题