squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

commit 47db6a9b1424184d7abe32416032960130a17403
parent 76eb0785a936414f740c0cbf936174112c9eb303
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Wed, 15 Jan 2020 12:46:39 -0600

Replace append with append_lists

Implemented a custom version of the append predicate, which is
not defined in the ISO specification.

Diffstat:
Mgenerate_rss.pl | 22+++++++++++-----------
Mhelpers.pl | 13+++++++++++--
2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/generate_rss.pl b/generate_rss.pl @@ -51,18 +51,18 @@ get_link(Filename, Link):- atom_codes(Filename, FilenameCodes), % Just assert that this is an index file before we go further. % Backtracking after this point will take us down a rabbit hole. - append(_, "index.md", FilenameCodes), + append_lists(_, "index.md", FilenameCodes), site_url(URL, []), - append(_, "/source", StartPath), - append(StartPath, Path, FilenameCodes), - append(PathWithoutFile, "index.md", Path), - append(URL, PathWithoutFile, Link). + append_lists(_, "/source", StartPath), + append_lists(StartPath, Path, FilenameCodes), + append_lists(PathWithoutFile, "index.md", Path), + append_lists(URL, PathWithoutFile, Link). get_link(Filename, Link):- atom_codes(Filename, FilenameCodes), site_url(URL, []), - append(_, "/source", StartPath), - append(StartPath, Path, FilenameCodes), - append(PathWithoutExtension, ".md", Path), - append(PathWithoutExtension, "/", PathWithSlash), - append(URL, PathWithSlash, Link).- \ No newline at end of file + append_lists(_, "/source", StartPath), + append_lists(StartPath, Path, FilenameCodes), + append_lists(PathWithoutExtension, ".md", Path), + append_lists(PathWithoutExtension, "/", PathWithSlash), + append_lists(URL, PathWithSlash, Link).+ \ No newline at end of file diff --git a/helpers.pl b/helpers.pl @@ -34,14 +34,23 @@ take_append(_, Item, ResultSoFar, [Item|ResultSoFar]). replace(_, _, [], []). replace(FindCodes, ReplaceCodes, Haystack, Result):- - append(FindCodes, HaystackMinusMatch, Haystack), + append_lists(FindCodes, HaystackMinusMatch, Haystack), replace(FindCodes, ReplaceCodes, HaystackMinusMatch, ReplacedHaystackMinusMatch), - append(ReplaceCodes, ReplacedHaystackMinusMatch, Result). + append_lists(ReplaceCodes, ReplacedHaystackMinusMatch, Result). replace(FindCodes, ReplaceCodes, [Code|Haystack], [Code|Result]):- replace(FindCodes, ReplaceCodes, Haystack, Result). +% append_lists(?List1, ?List2, ?Result). +% Append two lists. +% This is not an ISO predicate, so I've definded it here for portability. +append_lists([], List2, List2). + +append_lists([First|List1], List2, [First|Result]):- + append_lists(List1, List2, Result). + + anything([]) --> []. anything([X|Rest]) --> [X], anything(Rest).