on master help sign in
docs for filtered /_
062d509Ted Blackman
docs/arvo/internals/ford/runes.md+18−1
@@ -187,7 +187,9 @@ need to be enclosed in `/`'s: `/& html /elem/`
187
187
188### `/_` run a horn on each file in the current directory
188### `/_` run a horn on each file in the current directory
189
189
190+`/_` can be used in two ways: filtered and unfiltered.
191+
190−`/_` takes a horn as an argument. It produces a new horn representing the
192+Unfiltered `/_` takes a horn as an argument. It produces a new horn representing the
191result of mapping the supplied horn over the list of files in the current
193result of mapping the supplied horn over the list of files in the current
192directory. The keys in the resulting map are the basenames of the files in the
194directory. The keys in the resulting map are the basenames of the files in the
193directory, and each value is the result of running that horn on the contents of
195directory, and each value is the result of running that horn on the contents of
@@ -206,6 +208,21 @@ contents of the file through the `%hoon` mark, which validates that it's valid
206hoon code and returns it unmodified. So, the resulting map associates basenames
208hoon code and returns it unmodified. So, the resulting map associates basenames
207with file contents.
209with file contents.
208
210
211+Filtered `/_` takes an aura and a horn, and filters the list of files in the
212+current directory by whether their filenames can be parsed to an atom of that
213+aura. It then produces a map where each key is the filename after parsing into
214+that atom type, and each value is the result of running the horn on the
215+contents of that file.
216+
217+Example:
218+```
219+/= timed-posts /_ @da /md/
220+`(map @da @t)`timed-posts
221+```
222+produces a map from dates to cords. This product will only contain files whose
223+names are parsable into `@da` dates. The values are the file contents converted
224+to a cord of markdown-formatted text.
225+
209### `/;` operate on
226### `/;` operate on
210
227
211`/;` takes a twig and a horn. The twig should evaluate to a gate, which is then slammed
228`/;` takes a twig and a horn. The twig should evaluate to a gate, which is then slammed