Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: Whack a mole
From: "Daniel Ajoy" <da.ajoy@xxxxxxxxx>
Date: Wed, 14 Nov 2007 19:37:38 -0500
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;

--------------------------------------------------
On 14 Nov 2007 at 14:08, Burke, Bridget - CKJH wrote:

> We are working on a whack a mole project. 
> Is there a way to have a turtle report if it is touching 
> another turtle and the  turtle it is hitting has a certain 
> shape? 
>  
> if touching? "t1 "t2 and if t1's shape = 1 [t1, home] 
>  
> This does not seem to work. 

in proper Logo only arithmetic operators are infix

>From the wikipedia:

"Operator position indicates where, in the sequence, the 
operator appears. In terms of operator position, an 
operator may be prefix, postfix, or infix. A prefix 
operator immediately precedes its operand, as in "-x". A 
postfix operator immediately succeeds its operand, as in 
"x!". An infix operator exists between its left and right 
operands, as in "A + B"."


"and" is a function that receives two truth values, and
returns a truth value, just like "random" is a function that 
receives a number and returns a number.

functions in Logo are "prefix", they go before the inputs.

so, try this:

if and (touching? "t1 "t2) (1 = t1's shape) [t1, home] 

or simply:

if and touching? "t1 "t2 1 = t1's shape [t1, home] 


Daniel
OpenWorld Learning




  • Previous by thread: RE: Whack a mole
  • Next by thread: Re: Coding breakout paddle

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008