(map link-expander list-of-links)
I wonder what it looks like in Arc. Does HN keep any of its codebase public? (map link-expander list-of-links)
I wonder what it looks like in Arc. Does HN keep any of its codebase public?FWIW, here's the Arc code I wrote to generate a string of the form "Italicized Title - https://news.ycombinator.com/item?id=$ID - Month Year (n comments)". The variable i stands for item, which is HN's term for a post (story, comment, or poll):
(def biblioref (i)
(let mon (monthdate (date i!time) 'short)
(tostring
(if (astorypoll i)
(do (pr "*" (subst i!title "*" "\\*") "* - " (fullurl:item-url i!id)
" - " mon" (" (plural i!klive "comment") ")"))
(do (pr (fullurl:item-url i!id))
(unless (is mon (monthdate (date) 'short))
(pr " (" mon ")")))))))
Not that elegant but maybe not too bad.Here's one I use to decide from a list of free-form submissions whether to generate a link or a Google search:
(fn [pair-of]
(let [text (get pair-of 1)]
(cond
(clojure.string/starts-with? text "http")
(list [:a {:href text} (truncate text 60)] [:br])
:else (list [:a {:href (str "https://google.com/search?q=" text)} text] [:br]))))
Doesn't always work but works often enough! ;)