Simple-symbols.xhtml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  3. <head>
  4. <title>Simple symbols</title>
  5. <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
  6. <link rel="stylesheet" type="text/css" href="kawa.css"/>
  7. <script src="kawa-ebook.js" type="text/javascript"/>
  8. <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
  9. <link rel="prev" href="Symbols-and-namespaces.xhtml" title="Symbols and namespaces"/>
  10. <link rel="next" href="Namespaces.xhtml" title="Namespaces and compound symbols"/>
  11. </head>
  12. <body>
  13. <header/>
  14. <section class="sect1" title="Simple symbols" epub:type="subchapter" id="Simple-symbols">
  15. <div class="titlepage">
  16. <div>
  17. <div>
  18. <h2 class="title" style="clear: both">Simple symbols</h2>
  19. </div>
  20. </div>
  21. </div>
  22. <p>Simple symbols have no properties other than their name, an immutable string.
  23. They have the useful property that two simple symbols
  24. are identical (in the sense of <code class="literal">eq?</code>, <code class="literal">eqv?</code> and
  25. <code class="literal">equal?</code>) if and only if their names are spelled the same way. A
  26. symbol literal is formed using <code class="literal">quote</code>.
  27. </p>
  28. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877702624" class="indexterm"/> <code class="function">symbol?</code> <em class="replaceable"><code><em class="replaceable"><code>obj</code></em></code></em></p>
  29. <div class="blockquote">
  30. <blockquote class="blockquote">
  31. <p>Return <code class="literal">#t</code> if <em class="replaceable"><code>obj</code></em> is a symbol, <code class="literal">#f</code> otherwise.
  32. </p>
  33. <pre class="screen">(symbol? 'foo) ⇒ #t
  34. (symbol? (car '(a b))) ⇒ #t
  35. (symbol? "bar") ⇒ #f
  36. (symbol? 'nil) ⇒ #t
  37. (symbol? '()) ⇒ #f
  38. (symbol? #f) ⇒ #f
  39. </pre>
  40. </blockquote>
  41. </div>
  42. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877697264" class="indexterm"/> <code class="function">symbol-&gt;string</code> <em class="replaceable"><code><em class="replaceable"><code>symbol</code></em></code></em></p>
  43. <div class="blockquote">
  44. <blockquote class="blockquote">
  45. <p>Return the name of <em class="replaceable"><code>symbol</code></em> as an immutable string.
  46. </p>
  47. <pre class="screen">(symbol-&gt;string 'flying-fish) ⇒ "flying-fish"
  48. (symbol-&gt;string 'Martin) ⇒ "Martin"
  49. (symbol-&gt;string (string-&gt;symbol "Malvina")) ⇒ "Malvina"
  50. </pre>
  51. </blockquote>
  52. </div>
  53. <p class="synopsis" kind="Procedure"><span class="kind">Procedure</span><span class="ignore">: </span><a id="idm139667877692656" class="indexterm"/> <code class="function">string-&gt;symbol</code> <em class="replaceable"><code><em class="replaceable"><code>string</code></em></code></em></p>
  54. <div class="blockquote">
  55. <blockquote class="blockquote">
  56. <p>Return the symbol whose name is <em class="replaceable"><code>string</code></em>.
  57. </p>
  58. <pre class="screen">(eq? 'mISSISSIppi 'mississippi)
  59. ⇒ #f
  60. (string-&gt;symbol "mISSISSIppi")
  61. ⇒ the symbol with name "mISSISSIppi"
  62. (eq? 'bitBlt (string-&gt;symbol "bitBlt"))
  63. ⇒ #t
  64. (eq? 'JollyWog (string-&gt;symbol (symbol-&gt;string 'JollyWog)))
  65. ⇒ #t
  66. (string=? "K. Harper, M.D."
  67. (symbol-&gt;string (string-&gt;symbol "K. Harper, M.D.")))
  68. ⇒ #t
  69. </pre>
  70. </blockquote>
  71. </div>
  72. </section>
  73. <footer>
  74. <div class="navfooter">
  75. <p>
  76. Up: <a accesskey="u" href="Symbols-and-namespaces.xhtml">Symbols and namespaces</a></p>
  77. <p>
  78. Next: <a accesskey="n" href="Namespaces.xhtml">Namespaces and compound symbols</a></p>
  79. </div>
  80. </footer>
  81. </body>
  82. </html>