logo-lang


Working with lists in LOGO


I'm trying a recursive program in ACSLogo (a mac version of Logo) and want to return a list of 2 integers (basically and X coordinate and a Y coordinate). I cannot figure out how to get it to return 2 values. It does one no problem.
Also, when you create a list and you wish to refer back to it to extract a value in a particular index, it seems like you have to paste the list as is and you cannot refer to it by an assigned name.
Example:
Item 4 [1 1 2 3 5 8 13 21]
You cannot name that list "fibb" and refer to it like this X + fibb item 4
You can assign a list to a variable name like this:
Make "locations [1 1 2 3 5 8 13 21]
You can then access one of the items in the list like this:
Item 1 :locations
For instance, to set a variable named x equal to the second item, you could do this:
Make "x (Item 2 :locations)
Next, to make a new list from two different values, you can use the List command, for instance:
Make "location (List 1 2)
Or, from variables:
Make "location (List :x :y)
So, to get an x and y coordinate out of a list of locations and then create a new location variable containing both the x and y values, you could do this:
Make "locations [1 1 2 3 5 8 13 21]
Make "x (Item 1 :locations)
Make "y (Item 2 :locations)
Make "location (List :x :y)
Or, more simply:
Make "locations [1 1 2 3 5 8 13 21]
Make "location (List (Item 1 :locations) (Item 2 :locations))

Related Links

Working with lists in LOGO
Logo if statement
Return length of label, in pixels
How to catch command line arguments in Berkley Logo (UCBLogo)?
What are the drawbacks/weaknesses of using LOGO?
Which LOGO implementation? [closed]
How do I move the turtle in LOGO? [closed]
What is the current status of LOGO? (The programming language) [closed]

Categories

HOME
repository
msbuild
service
azure-eventhub
file-upload
android-webview
osx-yosemite
genexus
segmentation-fault
expo
opengrok
google-closure-compiler
background-image
template10
windows-phone
alert
views
datasource
turn.js
inline-assembly
procedural-generation
rvm
poisson
sha
android-xml
rancher
datanucleus
vtd-xml
arp
boost-log
exacttarget
scene7
javax
wit-ai
wunderground
ponylang
campaign-monitor
strategy-pattern
queryover
instances
nscollectionview
aspose.pdf
ui-grid
tapply
irr
peerjs
google-chrome-storage
ng-class
cancan
dotnet-cli
node-java
typewriter
overhead
nsalert
apache-commons-cli
group
msiexec
huawei
directinput
optional-parameters
zsh-completion
mongodb-3.3
mrunit
periodic-processing
firefox-os
dday
clear
yfiles
mojolicious
identifying
first-order-logic
roslyn-code-analysis
tooltwist
system.diagnostics
genero
accpac
beagleboard
caption
aiff
uiblureffect
mind-manager
qf-test
rpt
rda
lettuce
nodeunit
internet-radio
git-subtree
netbeans-plugins
fade
nsnumber
http-compression
reference-manual
gpl
antixsslibrary
motordriver
webpage-screenshot
derived-class
socketasynceventargs
jmesa
joomla1.7
capitalization
peoplepicker
cryptolicensing
azure-appfabric
rpxnow
data-formats
cons
paperless

Resources

Encrypt Message