<commit_before>..  Copyright © <NAME> and O'Reilly Media
.. |---| unicode:: U+2014  .. em dash, trimming surrounding whitespace
   :trim:

Symbols
:::::::::

Doing arithmetic with concrete numbers is fine, but when you move from arithmetic to algebra, you use variables so that you can manipulate abstract symbols. Similarly, in ClojureScript, you want to be able to describe transformations of data in abstract terms.  Before we talk about ClojureScript, let’s look a bit more closely at algebraic variables.

In algebra, when you say something like

    *x* = 5
    
that means that you are using the symbol *x* to represent 5. Wherever you have a 5, you can substitute *x*; wherever you have an *x*, you can substitute 5.  Similarly, when you say:
    
    *y* = *x* + 3
    
That means the symbol *y* represents the quantity *x* + 3, and you can substitute one for the other. 

Another feature of algebraic symbols is that, once you set them, you can’t change your mind. You can’t be halfway through a calculation and all of a sudden claim that:
    
    *x* = 6
    
because you said that *x* symbolizes 5, and five certainly does not equal six!


Symbols in ClojureScript
========================

Symbols in ClojureScript work much like algebraic values. You use the ``def`` function to **bind** a symbol to a value. 
The ``def`` function takes two arguments: the symbol and the value. Once a symbol is bound,
you can use it in expressions, including definitions of other symbols.

.. activecode:: symbol_def
    :caption: Define Symbol Bindings Here
    :language: clojurescript
    
    (def years 62)
    (def days (* 365 years))
    days

.. reveal:: nonprogrammer_sym
    :showtitle: Click to read this if you have not programmed before
    :hidetitle: Hide
    
    In many other programming languages, symbols are called *variables*, and they are not bound to values as in ClojureScript.<commit_msg>Minor wording change.<commit_after>..  Copyright © <NAME> and O'Reilly Media
.. |---| unicode:: U+2014  .. em dash, trimming surrounding whitespace
   :trim:

Symbols
:::::::::

Doing arithmetic with concrete numbers is fine, but when you move from arithmetic to algebra, you use variables so that you can manipulate abstract symbols. Similarly, in ClojureScript, you want to be able to describe transformations of data in abstract terms.  Before we talk about ClojureScript, let’s look a bit more closely at algebraic variables.

In algebra, when you say something like

    *x* = 5
    
that means that you are using the symbol *x* to represent 5. Wherever you have a 5, you can substitute *x*; wherever you have an *x*, you can substitute 5.  Similarly, when you say:
    
    *y* = *x* + 3
    
That means the symbol *y* represents the quantity *x* + 3, and you can substitute one for the other. 

Another feature of algebraic symbols is that, once you set them, you can’t change your mind. You can’t be halfway through a calculation and all of a sudden claim that:
    
    *x* = 6
    
because you said that *x* symbolizes 5, and five certainly does not equal six!


Symbols in ClojureScript
========================

Symbols in ClojureScript work much like in algebra. You use the ``def`` function to **bind** a symbol to a value. 
The ``def`` function takes two arguments: the symbol and the value. Once a symbol is bound,
you can use it in expressions, including definitions of other symbols.

.. activecode:: symbol_def
    :caption: Define Symbol Bindings Here
    :language: clojurescript
    
    (def years 62)
    (def days (* 365 years))
    days

.. reveal:: nonprogrammer_sym
    :showtitle: Click to read this if you have not programmed before
    :hidetitle: Hide
    
    In many other programming languages, symbols are called *variables*, and they are not bound to values as in ClojureScript.
{'fraction_non_alphanumeric': 0.08176593521421108, 'fraction_numerical': 0.008881922675026124, 'mean_word_length': 3.5692124105011933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5407094', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1006, 'n_words': 565}