1 #+Title: a collection of examples for Babel tests
3 * =:noweb= header argument expansion
5 :ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
8 #+source: noweb-example
13 #+begin_src emacs-lisp :noweb yes
19 #+begin_src emacs-lisp :noweb no
25 #+begin_src emacs-lisp :noweb tangle
31 * elisp forms in header arguments
33 :ID: 22d67284-bf14-4cdc-8319-f4bd876829d7
37 #+begin_src emacs-lisp
44 * excessive id links on tangling
46 :ID: ef06fd7f-012b-4fde-87a2-2ae91504ea7e
49 ** no, don't give me an ID
50 #+begin_src emacs-lisp :tangle no
51 (message "not to be tangled")
54 ** yes, I'd love an ID
56 :ID: ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3
58 #+begin_src emacs-lisp :tangle no
59 (message "for tangling")
61 * simple variable resolution
63 :ID: f68821bc-7f49-4389-85b5-914791ee3718
67 #+begin_src emacs-lisp
71 #+begin_src emacs-lisp :var four=four
78 * multi-line header arguments
80 :ID: b77c8857-6c76-4ea9-8a61-ddc2648d96c4
83 #+headers: :var letters='(a b c d e f g)
84 #+begin_src emacs-lisp :var numbers='(1 2 3 4 5 6 7)
85 (map 'list #'list numbers letters)
97 * simple named code block
99 :ID: 0d82b52d-1bb9-4916-816b-2c67c8108dbb
102 #+source: i-have-a-name
103 #+begin_src emacs-lisp
110 #+results: i-have-a-name
113 * Pascal's Triangle -- export test
115 :ID: 92518f2a-a46a-4205-a3ab-bcce1008a4bb
118 #+source: pascals-triangle
119 #+begin_src emacs-lisp :var n=5 :exports both
120 (defun pascals-triangle (n)
123 (let* ((prev-triangle (pascals-triangle (- n 1)))
124 (prev-row (car (reverse prev-triangle))))
125 (append prev-triangle
127 (append prev-row '(0))
128 (append '(0) prev-row)))))))
133 * calling code blocks from inside table
135 :ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
139 #+begin_src emacs-lisp :var n=9
143 * executing an lob call line
146 :ID: fab7e291-fde6-45fc-bf6e-a485b8bca2f0
149 #+call: echo(input="testing")
150 #+call: echo(input="testing") :results vector
151 #+call: echo[:var input="testing"]()
152 #+call: echo[:var input="testing"]() :results vector
153 #+call: echo("testing")
154 #+call: echo("testing") :results vector
156 * parsing header arguments
158 :ID: 7eb0dc6e-1c53-4275-88b3-b22f3113b9c3
161 #+begin_src example-lang :session :results output :var num=9
164 * conflicting blocks on export
166 :ID: 5daa4d03-e3ea-46b7-b093-62c1b7632df3
173 #+begin_src emacs-lisp :results wrap :exports both
176 #+begin_src emacs-lisp :var lst=a-list :results list
179 * using the =:noweb-ref= header argument
181 :ID: 54d68d4b-1544-4745-85ab-4f03b3cbd8a0
184 #+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
188 ** query all mounted disks
189 #+begin_src sh :noweb-ref fullest-disk
193 ** strip the header row
194 #+begin_src sh :noweb-ref fullest-disk
198 ** sort by the percent full
199 #+begin_src sh :noweb-ref fullest-disk
200 |awk '{print $5 " " $6}'|sort -n |tail -1 \
203 ** extract the mount point
204 #+begin_src sh :noweb-ref fullest-disk