Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I felt the same about Lisps initially so I feel your pain :-)</p> <p>However the good news is that you'll find that with a bit of time and regular usage you will probably start to like prefix notation. In fact with the exception of mathematical expressions I now prefer it to infix style.</p> <p>Reasons to like prefix notation:</p> <ul> <li><strong>Consistency with functions</strong> - most languages use a mix of infix (mathematical operators) and prefix (functional call) notation . In Lisps it is all consistent which has a certain elegance if you consider mathematical operators to be functions</li> <li><strong>Macros</strong> - become much more sane if the function call is always in the first position.</li> <li><strong>Varargs</strong> - it's nice to be able to have a variable number of parameters for pretty much all of your operators. <code>(+ 1 2 3 4 5)</code> is nicer IMHO than <code>1 + 2 + 3 + 4 + 5</code></li> </ul> <p>A trick then is to use <code>-&gt;</code> and <code>-&gt;&gt;</code> librerally when it makes logical sense to structure your code this way. This is typically useful when dealing with subsequent operations on objects or collections, e.g.</p> <pre><code>(-&gt;&gt; "Hello World" distinct sort (take 3)) ==&gt; (\space \H \W) </code></pre> <p>The final trick I found very useful when working in prefix style is to make good use of <strong>indentation</strong> when building more complex expressions. If you indent properly, then you'll find that prefix notation is actually quite clear to read:</p> <pre><code>(defn add-foobars [x y] (+ (bar x y) (foo y) (foo x))) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload