<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
nikhil wrote at 04/30/2011 01:45 AM:<br>
<blockquote
cite="mid:BANLkTimWJ2encQhTjor-9PJgNDX+S5S93g@mail.gmail.com"
type="cite">
<p
style="border-width: 0px; margin: 0px 0px 1em; padding: 0px; vertical-align: baseline; background-color: transparent; clear: both;"><font
class="Apple-style-span"
face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><span
class="Apple-style-span"
style="border-collapse: collapse; font-size: 14px; line-height: 18px;">How
do I return/print both ?</span></font></p>
</blockquote>
<br>
There are a few different ways. Which you choose depends on what you
are trying to do. Here is a program that you can paste into DrRacket
and run for some examples:<br>
<br>
#lang racket<br>
<br>
(display "\nYour original code:\n")<br>
(let ((var `(make))<br>
(exp '(1 2)))<br>
(cond [(number? 2)<br>
`(hi ,var)<br>
`(bye ,exp)]))<br>
<br>
(display "\nReturning a single list that includes the other two
lists:\n")<br>
(let ((var `(make))<br>
(exp '(1 2)))<br>
(cond [(number? 2)<br>
`((hi ,var)<br>
(bye ,exp))]))<br>
<br>
(display "\nUsing \"values\" to return multiple values instead of just
one (this is usually for advanced programmers only):\n")<br>
(let ((var `(make))<br>
(exp '(1 2)))<br>
(cond [(number? 2)<br>
(values `(hi ,var)<br>
`(bye ,exp))]))<br>
<br>
(display "\nUsing \"printf\" to display values rather than return them
from the expression:\n")<br>
(let ((var `(make))<br>
(exp '(1 2)))<br>
(cond [(number? 2)<br>
(printf "~S\n" `(hi ,var))<br>
(printf "~S\n" `(bye ,exp))<br>
"this is the actual returned value"]))<br>
<br>
(display "\nUsing \"log-debug\" to send values to the log (see DrRacket
\"View -> Show Log\" menu item):\n")<br>
(let ((var `(make))<br>
(exp '(1 2)))<br>
(cond [(number? 2)<br>
(log-debug (format "~S" `(hi ,var)))<br>
(log-debug (format "~S" `(bye ,exp)))<br>
"this is the actual returned value"]))<br>
<br>
<br>
<div class="moz-signature">-- <br>
<a class="moz-txt-link-freetext" href="http://www.neilvandyke.org/">http://www.neilvandyke.org/</a>
</div>
</body>
</html>