Files
uni/third/semester1/CT331: Programming Paradigms/assignments/assignment2/latex/_minted-CT331-Assignment-2/2B2C2C5067A5C85E076A998DEBE8BA662310CE7020B3E4C6B774EC9329C69276.pygtex

25 lines
2.2 KiB
Plaintext

\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
\PYG{k+kn}{\PYGZsh{}lang }\PYG{n+nn}{racket}
\PYG{c+c1}{;; a cons pair of two numbers}
\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{1}\PYG{+w}{ }\PYG{l+m+mi}{2}\PYG{p}{)}
\PYG{c+c1}{;; a list of 3 numbers using only the cons function}
\PYG{c+c1}{;; this could be more easily done using the single quote `'` (i.e., `'(1 2 3)`) but i don't use it as it seemed against the spirit of the question}
\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{1}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{2}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{3}\PYG{+w}{ }\PYG{n+nb}{empty}\PYG{p}{)))}\PYG{+w}{ }
\PYG{c+c1}{;; a list containing a string, a number, and a nested list of three numbers using only the cons function}
\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+s+s2}{\PYGZdq{}a string\PYGZdq{}}
\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{0}\PYG{+w}{ }
\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{1}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{2}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{cons}\PYG{+w}{ }\PYG{l+m+mi}{3}\PYG{+w}{ }\PYG{n+nb}{empty}\PYG{p}{)))}\PYG{+w}{ }\PYG{n+nb}{empty}\PYG{p}{)}
\PYG{+w}{ }\PYG{p}{)}
\PYG{p}{)}
\PYG{c+c1}{;; a list containing a string, a number, and a nested list of three numbers, using only the list function}
\PYG{p}{(}\PYG{n+nb}{list}\PYG{+w}{ }\PYG{l+s+s2}{\PYGZdq{}a string\PYGZdq{}}\PYG{+w}{ }\PYG{l+m+mi}{0}\PYG{+w}{ }\PYG{p}{(}\PYG{n+nb}{list}\PYG{+w}{ }\PYG{l+m+mi}{1}\PYG{+w}{ }\PYG{l+m+mi}{2}\PYG{+w}{ }\PYG{l+m+mi}{3}\PYG{p}{))}
\PYG{c+c1}{;; a list containing a string, a number, and a nested list of three numbers, using only the append function}
\PYG{c+c1}{;; using `'` as the arguments of the `append` function must be themselves lists}
\PYG{p}{(}\PYG{n+nb}{append}\PYG{+w}{ }\PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}a string\PYGZdq{}}\PYG{p}{)}\PYG{+w}{ }\PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{l+m+mi}{0}\PYG{p}{)}\PYG{+w}{ }\PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{p}{(}\PYG{l+m+mi}{1}\PYG{+w}{ }\PYG{l+m+mi}{2}\PYG{+w}{ }\PYG{l+m+mi}{3}\PYG{p}{)))}
\end{Verbatim}