Changes between Version 69 and Version 70 of Clojure Client Tutorial


Ignore:
Timestamp:
Aug 23, 2011 12:46:18 PM (13 years ago)
Author:
kedwar10
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Clojure Client Tutorial

    v69 v70  
    8787== Client Usage Tutorial ==
    8888
    89 === Summary ===
     89=== Introduction ===
    9090The client has several ways of writing messages to the server, each of which has different behaviour with respect to synchronization and reply processing.  The user must specify the way these functions operate by passing them data structures and functions which will be called on the data returned from the server.  This is analogous to the "reduce" or "foldl" functions found in Clojure and Scheme respectively.  If you are unfamiliar with using functions as arguments, then it may be worthwhile to experiment with in the REPL with either "map" or "reduce".  For example, 
     91
     92{{{
     93user=> (map inc [1 2 3 4 5])
     94(2 3 4 5 6)
     95user=> (map (fn [e] (* e 2)) [1 2 3 4 5]) ; an anonymous function
     96(2 4 6 8 10)
     97user=> (map #(* % 2) [1 2 3 4 5]) ; same, but with alternative syntax       
     98(2 4 6 8 10)
     99user=> ((juxt inc dec) 1)         
     100[2 0]
     101}}}
     102
     103The client behaviour more closely corresponds to the "reduce" function.
     104
     105{{{
     106user=> (reduce + [1 2 3 4 5])
     10715
     108}}}
    91109
    92110=== Basic Functionality ===
     
    114132}}}
    115133
    116 For example:
     134For example,
    117135
    118136{{{