PageSourceSearch

https://lisp-docs.github.io/cl-language-reference/assets/js/3c974243.8a01b5a7.js

js lisp-docs.github.io collected 2026-10-03 09:34:28 UTC 8,010 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkcl_language_reference||=[]).push([[4632],{73268(e,n,s){s.r(n),s.d(n,{assets:()=>p,contentTitle:()=>a,default:()=>y,frontMatter:()=>d,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"chap-10/ba-c-dictionary/symbolp_function","title":"symbolp","description":"Expanded Reference: symbolp","source":"@site/docs/chap-10/ba-c-dictionary/symbolp_function.md","sourceDirName":"chap-10/ba-c-dictionary","slug":"/chap-10/ba-c-dictionary/symbolp_function","permalink":"/cl-language-reference/chap-10/ba-c-dictionary/symbolp_function","draft":false,"unlisted":false,"editUrl":"https://github.com/lisp-docs/cl-language-reference/tree/main/docs/chap-10/ba-c-dictionary/symbolp_function.md","tags":[],"version":"current","lastUpdatedBy":"daninus14","frontMatter":{"title":"symbolp"},"sidebar":"tutorialSidebar","previous":{"title":"symbol","permalink":"/cl-language-reference/chap-10/ba-c-dictionary/symbol_system-class"},"next":{"title":"unbound-variable","permalink":"/cl-language-reference/chap-10/ba-c-dictionary/unbound-variable_condition-type"}}');var r=s(74848),i=s(28453);function o(e){const n={code:"code",em:"em",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components},{DictionaryLink:s,GlossaryTerm:l}=n;return s||t("DictionaryLink",!0),l||t("GlossaryTerm",!0),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"symbolp"})," ",(0,r.jsx)(l,{term:"function",children:(0,r.jsx)("i",{children:"Function"})})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Syntax:"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(s,{term:"symbolp",children:(0,r.jsx)("b",{children:"symbolp"})})," ",(0,r.jsx)(n.em,{children:"object \u2192 generalized-boolean"})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Arguments and Values:"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(l,{term:"object",children:(0,r.jsx)("i",{children:"object"})}),"\u2014an ",(0,r.jsx)(l,{term:"object",children:(0,r.jsx)("i",{children:"object"})}),"."]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.em,{children:"generalized-boolean"}),"\u2014a ",(0,r.jsx)(l,{styled:!0,term:"generalized boolean",children:(0,r.jsx)("i",{children:"generalized boolean"})}),"."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Description:"})}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(l,{term:"true",children:(0,r.jsx)("i",{children:"true"})})," if ",(0,r.jsx)(l,{term:"object",children:(0,r.jsx)("i",{children:"object"})})," is of ",(0,r.jsx)(l,{term:"type",children:(0,r.jsx)("i",{children:"type"})})," ",(0,r.jsx)(s,{term:"symbol",children:(0,r.jsx)("b",{children:"symbol"})}),"; otherwise, returns ",(0,r.jsx)(l,{term:"false",children:(0,r.jsx)("i",{children:"false"})}),"."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Examples:"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:'(symbolp \u2019elephant) \u2192 true \n(symbolp 12) \u2192 false \n(symbolp nil) \u2192 true \n(symbolp \u2019()) \u2192 true \n(symbolp :test) \u2192 true \n(symbolp "hello") \u2192 false \n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"See Also:"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(s,{term:"keywordp",children:(0,r.jsx)("b",{children:"keywordp"})}),", ",(0,r.jsx)(s,{term:"symbol",children:(0,r.jsx)("b",{children:"symbol"})}),", ",(0,r.jsx)(s,{term:"typep",children:(0,r.jsx)("b",{children:"typep"})})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Notes:"})}),"\n",(0,r.jsxs)(n.p,{children:["(symbolp ",(0,r.jsx)(l,{term:"object",children:(0,r.jsx)("i",{children:"object"})}),") ",(0,r.jsx)(n.em,{children:"\u2261"})," (typep ",(0,r.jsx)(l,{term:"object",children:(0,r.jsx)("i",{children:"object"})})," \u2019symbol)"]})]})}function c(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}function t(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}const d={title:"symbolp"},a="symbolp",p={},h=[{value:"Expanded Reference: symbolp",id:"expanded-reference-symbolp",level:2},{value:"Basic type checking",id:"basic-type-checking",level:3},{value:"NIL and T are symbols",id:"nil-and-t-are-symbols",level:3},{value:"Keywords are symbols",id:"keywords-are-symbols",level:3},{value:"Non-symbol types",id:"non-symbol-types",level:3},{value:"Equivalence with typep",id:"equivalence-with-typep",level:3},{value:"Filtering symbols from a mixed list",id:"filtering-symbols-from-a-mixed-list",level:3}];function m(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"symbolp",children:"symbolp"})}),"\n","\n",(0,r.jsx)(c,{}),"\n",(0,r.jsx)(n.h2,{id:"expanded-reference-symbolp",children:"Expanded Reference: symbolp"}),"\n",(0,r.jsx)(n.h3,{id:"basic-type-checking",children:"Basic type checking"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"symbolp"})," returns true if the object is a symbol, and false otherwise."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(symbolp 'hello)\n=> T\n(symbolp 'car)\n=> T\n(symbolp 42)\n=> NIL\n(symbolp \"hello\")\n=> NIL\n(symbolp #\\A)\n=> NIL\n"})}),"\n",(0,r.jsx)(n.h3,{id:"nil-and-t-are-symbols",children:"NIL and T are symbols"}),"\n",(0,r.jsxs)(n.p,{children:["Both ",(0,r.jsx)(n.code,{children:"nil"})," and ",(0,r.jsx)(n.code,{children:"t"})," are symbols, even though they also serve as boolean values."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(symbolp nil)\n=> T\n(symbolp t)\n=> T\n(symbolp '())\n=> T\n"})}),"\n",(0,r.jsx)(n.h3,{id:"keywords-are-symbols",children:"Keywords are symbols"}),"\n",(0,r.jsxs)(n.p,{children:["Keywords are a subtype of symbol, so ",(0,r.jsx)(n.code,{children:"symbolp"})," returns true for them."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(symbolp :test)\n=> T\n(symbolp :key)\n=> T\n"})}),"\n",(0,r.jsx)(n.h3,{id:"non-symbol-types",children:"Non-symbol types"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"symbolp"})," returns false for all non-symbol objects, including lists, arrays, and functions."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(symbolp '(a b c))\n=> NIL\n(symbolp #(1 2 3))\n=>
1 NIL\n(symbolp #'car)\n=> NIL\n(symbolp 3.14)\n=> NIL\n"})}),"\n",(0,r.jsx)(n.h3,{id:"equivalence-with-typep",children:"Equivalence with typep"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"symbolp"})," is equivalent to testing with ",(0,r.jsx)(n.code,{children:"typep"})," for the type ",(0,r.jsx)(n.code,{children:"symbol"}),"."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(let ((x 'foo))\n  (eq (symbolp x) (typep x 'symbol)))\n=> T\n\n(let ((x 42))\n  (eq (symbolp x) (typep x 'symbol)))\n=> T\n"})}),"\n",(0,r.jsx)(n.h3,{id:"filtering-symbols-from-a-mixed-list",children:"Filtering symbols from a mixed list"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"symbolp"})," is useful as a predicate with higher-order functions."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lisp",children:"(remove-if-not #'symbolp '(a 1 b \"c\" :d 2 nil))\n=> (A B :D NIL)\n"})})]})}function y(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(m,{...e})}):m(e)}},28453(e,n,s){s.d(n,{R:()=>o,x:()=>c});var l=s(96540);const r={},i=l.createContext(r);function o(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),l.createElement(i.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.