• Complain

J. David Eisenberg - Etudes for ClojureScript

Here you can read online J. David Eisenberg - Etudes for ClojureScript full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2015, publisher: OReilly Media, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

J. David Eisenberg Etudes for ClojureScript
  • Book:
    Etudes for ClojureScript
  • Author:
  • Publisher:
    OReilly Media
  • Genre:
  • Year:
    2015
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Etudes for ClojureScript: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Etudes for ClojureScript" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

A short composition that provides practice material for a particular musical skill is called an tude. In this hands-on book, youll find more than 30 tudes to help you practice ClojureScript skills for specific programming areas, ranging from functions and variables to asynchronous processing. Each of these small projects includes a description of a program that you will compose (write) in ClojureScript.

Though not as difficult as their musical counterparts, these programming tudes will help you stretch beyond the material and examples that you find in most ClojureScript books or online references. One chapter features tudes for an open-ended project that will help you put together what youve learned. Solutions to each tude are revealed in the appendix.

Programming areas include:

  • Working with functions and variables with def and let
  • Interacting with JavaScript and web pages, using several libraries
  • Lists, vectors, and higher-order map, filter, and reduce functions
  • Data mapping with ClojureScript
  • Using different ClojureScript libraries to program with React
  • Adding, subtracting, multiplying, and dividing rational and complex numbers with defprotocol and defrecord
  • Asynchronous processing with core.async

J. David Eisenberg: author's other books


Who wrote Etudes for ClojureScript? Find out the surname, the name of the author of the book and a list of all author's works by series.

Etudes for ClojureScript — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Etudes for ClojureScript" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
tudes for ClojureScript

Companion Exercises for Introducing ClojureScript

J. David Eisenberg

Etudes for ClojureScript

by J. David Eisenberg

Copyright 2016 J. David Eisenberg. All rights reserved.

Printed in the United States of America.

Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.

OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .

  • Editor: Brian Foster
  • Production Editor: Shiny Kalapurakkel
  • Copyeditor: Charles Roumeliotis
  • Proofreader: Amanda Kersey
  • Interior Designer: David Futato
  • Cover Designer: Karen Montgomery
  • Illustrator: Rebecca Demarest
  • December 2015: First Edition
Revision History for the First Edition
  • 2015-11-16: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781491934890 for release details.

While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.

978-1-491-93489-0

Preface
Whats an tude?

An tude, according to Wikipedia, is an instrumental musical composition, usually short and of considerable difficulty, usually designed to provide practice material for perfecting a particular musical skill.

What Are tudes for ClojureScript?

In this book, you will find descriptions of programs that you can compose (write) in ClojureScript. The programs will usually be short, and each one has been designed to provide practice material for a particular ClojureScript programming area. Unlike musical tudes, these programs have not been designed to be of considerable difficulty, though they may ask you to stretch a bit beyond the immediate material and examples that you find in most ClojureScript books or online references.

These tudes are not intended to introduce you to individual ClojureScript concepts. That ground is covered quite nicely by ClojureScript Koans, 4Clojure, and ClojureScript Unraveled. Instead, these tudes take the form of small projects that do something that is (somewhat) useful. They are much along the lines of the programming katas given in chapter 10 of Living Clojure by Carin Meier (OReilly). If Koans, 4Clojure, and ClojureScript Unraveled ask you to write programs at the level of chemical elements, in this book, you are constructing simple molecules.

This book is open source, so if youd like to contribute, make a correction, or otherwise participate in the project, check out https://github.com/oreillymedia/etudes_for_clojurescript for details. If we accept your work, well add you to the contributors chapter.

Acknowledgments

Thanks to OReilly Media, Inc.s Simon St. Laurent and Meghan Blanchette, who encouraged me to write this book. Thanks also to all the people on the #clojurescript IRC channel who patiently answered my questions, and to Mike Fikes for his technical review. Any errors remaining in this document are mine, not theirs.

Chapter 1. Functions and Variables

This chapter starts with a couple of warm-up exercises so that you can get comfortable with your ClojureScript development environment. First, a quick review of how to define functions. Here is the generic model for a function:

(defn function-name [parameters] function-body)

Here is a function that takes an acceleration and an amount of time as its parameters and returns the distance traveled:

(defn distance [accel time] (/ (* accel time time) 2.0)

You can also put a documentation string between the function name and parameter list:

(defn distance "Calculate distance traveled by an object moving with a given acceleration for a given amount of time." [accel time] (/ (* accel time time) 2.0)
tude 1-1: Defining a Function in the REPL

Create a project named formulas (see , and create a project to work with. In the REPL, type the preceding distance function and test it.

tude 1-2: Defining Functions in a Source File

Defining functions in the REPL is fine for a quick test, but it is not something you want to do on an application-level scale. Instead, you want to define the functions in a source file. In the formulas project, open the src/formulas/core.cljs file and create functions for these formulas:

  • Distance equals one-half acceleration multplied by time squared: Etudes for ClojureScript - image 1
  • Kinetic energy equals one-half the mass times velocity squared: Etudes for ClojureScript - image 2
  • Centripetal acceleration is velocity squared over the radius: Picture 3

Here is some sample output. (in-ns 'formulas.core) switches you to that namespace so that you can type the function name without having to specify the module that it is in. If you update the source, (require 'formulas.core :reload) will recompile the code:

cljs.user=> (in-ns 'formulas.core)nilformulas.core=> (require 'formulas.core :reload)nilformulas.core=> (distance 9.8 5)122.5formulas.core=> (kinetic-energy 35 4)280formulas.core=> (centripetal 30 2)450

See a suggested solution: .

tude 1-3: Using def

The def special form lets you bind a symbol to a value. The symbol is globally available to all functions in the namespace where it is defined. Add a function named gravitational-force that calculates the gravitational force between two masses whose centers of mass are at a distance r from each other to your code:

where the gravitational constant Use a def for the gravitational constant - photo 4, where the gravitational constant Use a def for the gravitational constant Here is the calculation for two - photo 5

Use a def for the gravitational constant.

Here is the calculation for two masses of 100 kg that are 5 m apart:

formulas.core=> (gravitational-force 100 100 5)2.67136e-8

Redefining and def

ClojureScripts def creates an ordinary JavaScript variable. Note that it is possible to rebind a symbol to a value with code like this:

(defx5)(defx6)(defx(+1
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Etudes for ClojureScript»

Look at similar books to Etudes for ClojureScript. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Etudes for ClojureScript»

Discussion, reviews of the book Etudes for ClojureScript and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.