Skip to content

Commit 9e77920

Browse files
committed
Move examples.janet next to gen-docs.janet
1 parent 978806e commit 9e77920

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

content/examples.janet

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(def replacer
2+
(peg/compile
3+
~(% (any (+ (/ '(set "%*/:<>?")
4+
,|(string "_" (0 $))) '1)))))
5+
6+
(defn sym-to-filename
7+
``
8+
Convert a symbol to a filename. Certain filenames are not allowed on
9+
various operating systems.
10+
``
11+
[fname]
12+
(string "examples/" ((peg/match replacer fname) 0) ".janet"))
13+
14+
(defn main
15+
[& args]
16+
(def symbol-name (get args 1))
17+
(assert symbol-name "please specify a symbol name")
18+
(print (string/slice (sym-to-filename symbol-name)
19+
(length "examples/"))))
20+

0 commit comments

Comments
 (0)