Skip to content

wdhowe/clojure-snippets

Repository files navigation

clojure-snippets

Clojure example snippets.

Short files that demonstrate syntax and concepts.


Execute

Run individual snippet files via clj -M FILENAME.

Example:

clj -M basic_syntax/hello_world.clj

Output

Hello Clojure world!

Descriptions

Snippets

  • abstractions -> Creating abstractions with multimethods, protocols, and records.
  • basic_syntax -> Getting started with basic syntax. (hello world, math operators, comparison operators, variables)
  • concurrency -> Processing on multiple threads concurrently. (futures, delays, promises, core.async)
  • data_structures -> Core data types and destructuring them. (lists, maps, sets, vectors)
  • file_operations -> Interacting with files and EDN for configuration.
  • flow_control -> Flow control concepts. (case, cond, exceptions, if, do, when)
  • functions -> Anonymous functions/lambda, multi-arity, composing functions, functions that accept and return functions (apply, partial).
  • http -> Http/get examples.
  • iter_recur -> Iteration and recursion.
  • java_interop -> Using Java's methods, objects, libraries.
  • macros -> Macro definition examples.
  • misc -> Miscellaneous items. (date, fizz buzz)
  • seq_col_funcs -> Core functions that operate against sequence elements and entire collections. (filter, map, reduce, etc)
  • state -> Using state like behavior. (atoms, watchers, validators)

Templates

  • template -> Template for a Clojure CLI/deps project with cli args.

Resources to Get Started