https://github.com/ilevd/cwp Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} ilevd / cwp Public * Notifications You must be signed in to change notification settings * Fork 0 * Star 42 Indentation-based syntax for Clojure License View license 42 stars 0 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights ilevd/cwp main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 40 Commits doc doc src-java/cwp src-java/cwp src src test/cwp test/cwp .gitignore .gitignore LICENSE LICENSE README.md README.md project.clj project.clj View all files Repository files navigation * README * License cwp alt words-count Clojars Project Indentation-based syntax for Clojure. Clojure is a practical dynamic functional programming language. This project provides familiar syntax, so it's easy to switch to it, from e.g. Python. Features: * Indentation-based, Python-like syntax * Easy to write math operations * In most cases separators: , - comma and to- keyword are optional * Readable Clojure code generation Being just a syntax for Clojure, it provides access to Clojure features such as: * Functional programming - immutable data structures, higher-order functions... * Concurrent primitives * Clojure/Java (JVM) ecosystem with a lot of libraries It's a transpiler and a Leiningen plugin. Examples Data manipulation def users: [{:name to "John", :age to 20} {:name to "Anna", :age to 32} {:name to "Smith", :age to 27}] def avg-age(users): let ages to users |>> map(:age) |>> reduce(+): ages / count(users) |> double def greetings(users): let names to users |>> map(:name) |>> str/join(", "): str("Hello, ", names, "!") println(avg-age(users)) println(greetings(users)) Simple HTTP server with http-kit, Hiccup and Ring ns my-project.server require: [ring.middleware.params :as params] [ring.middleware.keyword-params :as kparams] [org.httpkit.server :refer [run-server]] [hiccup2.core :as h] def fruits: ["Banana", "Apple", "Lemon"] def get-html(user): [:div [:p {:style {:font-weight :bold}} str("Hello, ", user or "User", "!")] "Fruits:" for fruit to fruits: [:p {} fruit]] |> h/html |> str def app(req): {:status 200 :headers {"Content-Type" "text/html"} :body get-html(req |> :params |> :name)} run-server(app |> kparams/wrap-keyword-params |> params/wrap-params, {:port 8080}) Some function from clojure.core rewritten with CWP def load-data-reader-file(mappings, ^java.net.URL url): with-open rdr to clojure.lang.LineNumberingPushbackReader.( java.io.InputStreamReader.( .openStream(url), "UTF-8")): binding *file* to .getFile(url): let read-opts to if .endsWith(.getPath(url), "cljc"): {:eof nil :read-cond :allow} else {:eof nil} new-mappings to read(read-opts, rdr): if not map?(new-mappings): throw ex-info(str("Not a valid data-reader map"), {:url url}) reduce(fn m, [k, v]: if not symbol?(k): throw ex-info(str("Invalid form in data-reader file"), {:url url :form k}) let v-var to data-reader-var(v): if contains?(mappings, k) and mappings(k) != v-var: throw ex-info("Conflicting data-reader mapping", {:url url :conflict k :mappings m}) assoc(m, k, v-var), mappings, new-mappings) Documentation * Overview * Syntax and transpiling Usage Add to project.clj :plugins section: [org.clojars.ilevd/cwp ""] Add builds info to project.clj root: :cwp {:builds [{:in "src-cwp" :out "src-out"}]} :in - folder where CWP sources are, :out - folder for generated Clojure code Files extensions mapping: * .cw -> .clj * .cws -> .cljs * .cwc -> .cljc Run: lein cwp After that you can compile Clojure code to .jar. License Copyright (c) 2024 ilevd About Indentation-based syntax for Clojure Resources Readme License View license Activity Stars 42 stars Watchers 2 watching Forks 0 forks Report repository Releases No releases published Packages 0 No packages published Languages * Java 89.5% * Clojure 10.5% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.