~jojo/Carth

ref: 749208029494a7c48ce04444a513424f4b998416 Carth/examples/literate.org -rw-r--r-- 809 bytes
74920802JoJo update TODO 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#+TITLE: Literate Programming Rules!

Literate programming is just really cool!

First we import the standard library.

#+BEGIN_SRC carth
(import std)
#+END_SRC

~carth~ will assume ~tangle~ = ~yes~ by default, but setting it
explicitly won't hurt.

#+BEGIN_SRC carth :tangle yes
(define main
  (display (identity "Literate programming rules!")))
#+END_SRC

* The ~identity~ function
  The ~identity~ function returns its argument unchanged.

  #+BEGIN_SRC carth
  (define (identity x) x)
  #+END_SRC

* How not to use ~identity~
  Here is an example of how not to use ~identity~. Note that this won't
  compile. We show this in a SRC block to get syntax highlighting etc,
  but as ~tangle~ is ~no~, this source block will be ignored by carth.

  #+BEGIN_SRC carth :tangle no
  (display identity)
  #+END_SRC