Skip to content

Pyons/clj-unglue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj unglue

Clojure unglue, inspired by https://github.com/moodymudskipper/unglue. Diverges on some key features like applying a function directly to the match.

Installation

{:deps
    {pyons/clj-unglue {:git/url "https://github.com/pyons/clj-unglue" 
                       :git/tag "v0.0.1" 
                       :git/sha "47ef778"}}}

Usage

Examples can be found in the test folder

(def puzzle
  "forward 5
down 5
forward 8
up 3
down 8
forward 2")

(defn read-lines [input]
  (let [lines (str/split-lines input)
        pattern "{direction=keyword} {units=parse-long}"]
    (unglue pattern lines)))

(read-lines puzzle)
;;=>
    [{:direction :forward, :units 5}
     {:direction :down, :units 5}
     {:direction :forward, :units 8}
     {:direction :up, :units 3}
     {:direction :down, :units 8}
     {:direction :forward, :units 2}]

Run the project's tests:

$ clojure -X:test:runner

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published