• Complain

Eisenberg J.D. - Études for ClojureScript: Companion Exercises for Introducing ClojureScript

Here you can read online Eisenberg J.D. - Études for ClojureScript: Companion Exercises for Introducing ClojureScript full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. 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.

Eisenberg J.D. Études for ClojureScript: Companion Exercises for Introducing ClojureScript
  • Book:
    Études for ClojureScript: Companion Exercises for Introducing ClojureScript
  • Author:
  • Genre:
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Études for ClojureScript: Companion Exercises for Introducing ClojureScript: summary, description and annotation

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

OReilly Media, 2015. 129 p. ISBN 10: 1-4919-3489-1, ISBN-13: 978-1-4919-3489-0. .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. iPAD Amazon Kindle, PC , Cool Reader (EPUB), Calibre (EPUB, MOBI, AZW3), Adobe Digital Editions (EPUB), FBReader (EPUB, MOBI, AZW3).

Eisenberg J.D.: author's other books


Who wrote Études for ClojureScript: Companion Exercises for Introducing ClojureScript? Find out the surname, the name of the author of the book and a list of all author's works by series.

Études for ClojureScript: Companion Exercises for Introducing 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 "Études for ClojureScript: Companion Exercises for Introducing 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
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: tudes for ClojureScript Companion Exercises for Introducing ClojureScript - image 1
  • Kinetic energy equals one-half the mass times velocity squared: tudes for ClojureScript Companion Exercises for Introducing 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(+1x))

However, this is somewhat frowned upon. Global, shared, mutable (changeable) variables can be problematic, as described in this answer to a question on StackExchange. You will find that ClojureScripts functional programming model makes the need for such global variables much less frequent. As a beginning programmer, when you create a variable with

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Études for ClojureScript: Companion Exercises for Introducing ClojureScript»

Look at similar books to Études for ClojureScript: Companion Exercises for Introducing 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 «Études for ClojureScript: Companion Exercises for Introducing ClojureScript»

Discussion, reviews of the book Études for ClojureScript: Companion Exercises for Introducing 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.