I don't know if this is the right place for a post about Scheme, but i was wondering if anyone knew if there are loops and if statements in Scheme? (I am very new to Scheme, i know there are 'cond' statements, but i don't know if there are if's, or if there's a difference between the two)
if there are in fact loops, an example of the syntax would be greatly appreciated.
Edited 4 Years Ago by pyTony: Moved to still not so appropriate Legacy forum
Scheme does have an if expression. It's used as
(if condition then-expression else-expression) and works in the obvious way (i.e. it evaluates
then-expression if the condition is true and
else-expression if its not - the result of evaluating an if expression is the result of whichever of
else-expression was evaluated).
The difference between
if is that
cond can take an arbitrary number of conditions and associated expressions, while
if takes only one condition.
cond also allows you to specify more than one expression for a given condition (which will be evaluated in order) - if you wanted to evaluate more than one expression with
if, you'd need to use
begin inside the
cond is basically a more versatile form of
The ways to do loops in Scheme are:
doform, which lets you specify a list of variables, that each have a starting value and an expression to calculate its new value, and a body. At the beginning of the loop each variable will be set to its starting value. While the condition evaluates to true, the body will be evaluated and after each iteration each variable will be set to the result of evaluating its respective expression. So basically it's a while-loop that allows you to specify how variables are updated declaritively.
For more information see the Scheme standard's section on iteration constructs.
¹ The Scheme standard mandates that a Scheme implementation must optimize tail recursion, so tail-recursive functions are an efficient way to implement loops in Schme.
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Hello All ...
Iam Getting An Error With try to excecute the stored procedure .
I have Have Sql database , the stored procedure like so :
USE [MPRS] GO /****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Here is the sample output that I ...