Practical Clojure (The Definitive Guide)

By Luke Van der Hart

This ebook is the 1st definitive reference for the Clojure language, delivering either an advent to sensible programming more often than not and a extra particular advent to Clojure’s gains. This booklet demonstrates using the language via examples, together with beneficial properties similar to STM and immutability, that could be new to programmers coming from different languages.
* review of practical programming and outline of what units Clojure except different languages
* precise clarification of Clojure’s specified features
* Examples of real-world projects which are well-suited to Clojure’s services, beginning with uncomplicated projects and relocating directly to extra complicated applications
<h3>What you’ll learn</h3> * What Clojure is—more than simply one other Lisp
* find out how to arrange a Clojure environment
* The constitution and syntax of a Clojure program
* Java interoperability
* find out how to use Clojure for real-world tasks
* universal idioms of Clojure code
<h3>Who is that this booklet for?</h3>
There are audiences for this publication: any technical individual meaning to be aware of what Clojure is and why they could are looking to use it, and any programmer intending to examine and use the language. The objectives of those audiences mesh properly, on condition that Clojure has numerous new, state of the art beneficial properties that programmers are not likely to have encountered sooner than.

Show description

Quick preview of Practical Clojure (The Definitive Guide) PDF

Best Java books

Mastering Lambdas: Java Programming in a Multicore World (Oracle Press)

The Definitive consultant to Lambda Expressions learning Lambdas: Java Programming in a Multicore global describes how the lambda-related gains of Java SE eight will permit Java to fulfill the demanding situations of next-generation parallel architectures. The ebook explains find out how to write lambdas, and the way to exploit them in streams and in assortment processing, offering code examples all through.

Mastering JavaFX 8 Controls (Oracle Press)

Layout and set up High-Performance JavaFX Controls carry cutting-edge functions with visually wonderful UIs. getting to know JavaFX eight Controls presents transparent directions, unique examples, and ready-to-use code samples. the way to paintings with the most recent JavaFX APIs, configure UI elements, immediately generate FXML, construct state of the art controls, and successfully observe CSS styling.

Data Abstraction and Problem Solving with Java: Walls and Mirrors (3rd Edition)

The 3rd variation of facts Abstraction and challenge fixing with Java: partitions and Mirrors employs the analogies of partitions (data abstraction) and Mirrors (recursion) to educate Java programming layout suggestions, in a fashion that starting scholars locate obtainable. The ebook has a student-friendly pedagogical method that rigorously debts for the strengths and weaknesses of the Java language.

Java Software Solutions: Foundations of Program Design (7th Edition)

Java software program suggestions teaches a starting place of programming thoughts to foster well-designed object-oriented software program. Heralded for its integration of small and massive life like examples, this all over the world best-selling textual content emphasizes construction sturdy problem-solving and layout abilities to put in writing top of the range courses.

Additional resources for Practical Clojure (The Definitive Guide)

Show sample text content

As a way to make sure that a ref you don’t replace is however unchanged after a transaction for coordination purposes, use determine on it in the transaction. Examples directory 6-1 illustrates the vintage instance of transactional habit formerly pointed out, moving funds from one checking account to a different. this can be a situation within which coordination among the 2 items of state—the accounts—is extremely important. If the values weren't coordinated, it'd be attainable, in spite of the fact that in brief, to be in a nation within which the cash was once further to at least one account yet now not but subtracted from the opposite (or vice versa). utilizing refs and transactions guarantees that the account addition and subtraction take place atomically. directory 6-1. financial institution bills in STM (def account1 (ref 1000)) (def account2 (ref 1500)) (defn move "transfers sum of money from a to b" [a b quantity] (dosync (alter a - quantity) (alter b + amount))) (transfer account1 account2 three hundred) (transfer account2 account1 50) one hundred and one CHAPTER 6 „ nation administration (println “Account #1:” @account1) (println “Account #2:” @account2) operating this code yields the predicted output after the 2 transactions. as the transaction is assured via Clojure’s STM, the implications often is the constant irrespective of what percentage threads have been simultaneously updating the bills. as a result, the output is: Account number one: 750 Account #2: 1750 the next instance is far extra complicated, and demonstrates how refs might be saved in any facts constitution (not simply def’d on the best level), how they could have any information constitution as their worth, not only integers, and the way even refs may be a part of the worth of one other ref. it's only a simple instance of utilizing refs: you'll likely are looking to strategy the ref constitution in a precise application with greatly extra inspiration. generally, it’s higher to be sensible and use as few refs as will meet your wishes. this system represents a rudimentary deal with publication. the most facts constitution is a vector of contacts. it's contained in a ref, because you have to be capable of replace it and it starts off out empty. every one touch is a map containing first identify and final identify. instead of storing the entries without delay, although, they're each one saved as a ref themselves, given that every one is an separately updateable piece of country (see directory 6-2). Lilsting 6-2. An tackle ebook in STM (def my-contacts (ref [])) (defn add-contact "adds a touch to the supplied touch checklist" [contacts touch] (dosync (alter contacts conj (ref contact)))) (defn print-contacts "prints an inventory of contacts" [contacts] (doseq [c @contacts] (println (str "Name: " (@c :lname) ", " (@c :fname))) )) (add-contact my-contacts {:fname "Luke" :lname "VanderHart"}) (add-contact my-contacts {:fname "Stuart" :lname "Sierra"}) (add-contact my-contacts {:fname "John" :lname "Doe"}) (print-contacts my-contacts) working the scripts creates a listing of contacts, provides a number of contacts to it (as refs), after which prints the record, yielding: identify: VanderHart , Luke identify: Sierra, Stuart identify: Doe, John 102 CHAPTER 6 „ country administration word how the print-contacts functionality must dereference the contacts record and in addition every one touch earlier than it could actually use it, on the grounds that either are references.

Download PDF sample

Rated 4.61 of 5 – based on 26 votes