Commit 3e0e3d88 authored by Gautham Velchuru's avatar Gautham Velchuru
Browse files

added more

parent 9098458a
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{set!} \PYG{n}{p} \PYG{l+m+mi}{5}\PYG{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{n+nb}{eval} \PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{l+s+ss}{+} \PYG{l+m+mi}{1} \PYG{l+m+mi}{2}\PYG{p}{))} \PYG{c+c1}{;; returns 3}
\PYG{p}{(}\PYG{n+nb}{apply} \PYG{n+nb}{+} \PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{l+m+mi}{1} \PYG{l+m+mi}{2} \PYG{l+m+mi}{3}\PYG{p}{))} \PYG{c+c1}{;; returns 6}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define} \PYG{n}{x} \PYG{l+m+mi}{10}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{define} \PYG{n}{y} \PYG{l+m+mi}{5}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{let} \PYG{p}{(}\PYG{p}{[}\PYG{n}{x} \PYG{l+m+mi}{15}\PYG{p}{]}
\PYG{p}{[}\PYG{n}{y} \PYG{p}{(}\PYG{n+nb}{+} \PYG{n}{x} \PYG{l+m+mi}{5}\PYG{p}{)])}
\PYG{n}{y}\PYG{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define} \PYG{n}{x} \PYG{p}{(}\PYG{n+nb}{list} \PYG{n}{y} \PYG{n}{z}\PYG{p}{))}
\PYG{p}{(}\PYG{k}{define} \PYG{n}{x} \PYG{p}{(}\PYG{n+nb}{cons} \PYG{p}{(}\PYG{n+nb}{cons} \PYG{n}{z} \PYG{o}{\PYGZsq{}}\PYG{p}{()))} \PYG{c+c1}{; \PYGZsq{}() is empty list}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define} \PYG{n}{s} \PYG{l+m+mi}{5}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{define} \PYG{p}{(}\PYG{n}{my\PYGZhy{}method} \PYG{n}{x}\PYG{p}{)}
\PYG{p}{(}\PYG{n+nb}{display} \PYG{p}{(}\PYG{n}{x}\PYG{p}{))} \PYG{c+c1}{;; will print 5}
\PYG{p}{(}\PYG{k}{set!} \PYG{n}{s} \PYG{l+m+mi}{6}\PYG{p}{)}
\PYG{p}{(}\PYG{n+nb}{display} \PYG{p}{(}\PYG{n}{x}\PYG{p}{)))} \PYG{c+c1}{;; will print 6}
\PYG{p}{(}\PYG{k}{define} \PYG{n}{x} \PYG{p}{(}\PYG{k}{lambda} \PYG{p}{()} \PYG{n}{s}\PYG{p}{))}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define} \PYG{n}{x} \PYG{p}{(}\PYG{k}{delay} \PYG{p}{(}\PYG{n+nb}{*} \PYG{l+m+mi}{2} \PYG{l+m+mi}{5}\PYG{p}{)))} \PYG{c+c1}{;not evaluated}
\PYG{p}{(}\PYG{k}{define} \PYG{n}{y} \PYG{p}{(}\PYG{n+nb}{force} \PYG{n}{x}\PYG{p}{))} \PYG{c+c1}{;evaluates, y is 10}
\PYG{p}{(}\PYG{k}{define} \PYG{n}{z} \PYG{p}{(}\PYG{n+nb}{force} \PYG{n}{x}\PYG{p}{))} \PYG{c+c1}{; does not evaluate again, z is also 10 (value is cached)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{n}{fn} \PYG{o+ow}{=} \PYG{n}{f}\PYG{o}{.} \PYG{n}{g} \PYG{o}{.} \PYG{n}{h}
\PYG{n}{fn} \PYG{n}{x} \PYG{o+ow}{=} \PYG{n}{f} \PYG{p}{(}\PYG{n}{g} \PYG{p}{(}\PYG{n}{h} \PYG{n}{x}\PYG{p}{))}\PYG{o}{.} \PYG{c+c1}{\PYGZhy{}\PYGZhy{} ew}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define} \PYG{n}{test\PYGZhy{}list} \PYG{o}{.} \PYG{n}{xs}
\PYG{p}{(}\PYG{n+nb}{length} \PYG{n}{xs}\PYG{p}{))}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{define\PYGZhy{}syntax\PYGZhy{}rule} \PYG{p}{(}\PYG{n}{swap} \PYG{n}{x} \PYG{n}{y}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{let} \PYG{p}{(}\PYG{p}{[}\PYG{n}{tmp} \PYG{n}{x}\PYG{p}{])}
\PYG{p}{(}\PYG{k}{set!} \PYG{n}{x} \PYG{n}{y}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{set!} \PYG{n}{y} \PYG{n}{tmp}\PYG{p}{)))}
\PYG{p}{(}\PYG{k}{define\PYGZhy{}syntax} \PYG{n}{rotate}
\PYG{p}{(}\PYG{k}{syntax\PYGZhy{}rules} \PYG{p}{()}
\PYG{p}{[}\PYG{p}{(}\PYG{n}{rotate} \PYG{n}{a} \PYG{n}{b}\PYG{p}{)} \PYG{p}{(}\PYG{n}{swap} \PYG{n}{a} \PYG{n}{b}\PYG{p}{)]}
\PYG{p}{[}\PYG{p}{(}\PYG{n}{rotate} \PYG{n}{a} \PYG{n}{b} \PYG{n}{c}\PYG{p}{)} \PYG{p}{(}\PYG{k}{begin}
\PYG{p}{(}\PYG{n}{swap} \PYG{n}{a} \PYG{n}{b}\PYG{p}{)}
\PYG{p}{(}\PYG{n}{swap} \PYG{n}{b} \PYG{n}{c}\PYG{p}{))]))}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{o}{\PYGZsq{}}\PYG{p}{(}\PYG{l+m+mi}{1} \PYG{l+m+mi}{2} \PYG{l+m+mi}{3} \PYG{o}{.} \PYG{l+m+mi}{4}\PYG{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{p}{(}\PYG{k}{letrec} \PYG{p}{(}\PYG{p}{[}\PYG{n}{is\PYGZhy{}even?} \PYG{p}{(}\PYG{k}{lambda} \PYG{p}{(}\PYG{n}{n}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{or} \PYG{p}{(}\PYG{n+nb}{zero?} \PYG{n}{n}\PYG{p}{)}
\PYG{p}{(}\PYG{n}{is\PYGZhy{}odd?} \PYG{p}{(}\PYG{n+nb}{sub1} \PYG{n}{n}\PYG{p}{))))]}
\PYG{p}{[}\PYG{n}{is\PYGZhy{}odd?} \PYG{p}{(}\PYG{k}{lambda} \PYG{p}{(}\PYG{n}{n}\PYG{p}{)}
\PYG{p}{(}\PYG{k}{and} \PYG{p}{(}\PYG{n+nb}{not} \PYG{p}{(}\PYG{n+nb}{zero?} \PYG{n}{n}\PYG{p}{))}
\PYG{p}{(}\PYG{n}{is\PYGZhy{}even?} \PYG{p}{(}\PYG{n+nb}{sub1} \PYG{n}{n}\PYG{p}{))))])}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k}{def} \PYG{n+nf}{number}
\PYG{l+m+mi}{2}
\PYG{k}{end}
\PYG{n+nb}{puts} \PYG{n}{number}
\end{Verbatim}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment