How to resolve the algorithm Variables step by step in the Logo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Variables step by step in the Logo programming language
Table of Contents
Problem Statement
Demonstrate a language's methods of:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Variables step by step in the Logo programming language
Source code in the logo programming language
make "g1 0
name 2 "g2 ; same as make with parameters reversed
global "g3 ; no initial value
to func :x
make "g4 4 ; still global
localmake "L1 6
local ["L2 "L3] ; local variables, collection syntax
func2 :g4
print :L2 ; 9, modified by func2
print :L3 ; L3 has no value, was not modified by func2
end
to func2 :y
make "g3 :y
make "L2 :L1 + 3 ; dynamic scope: can see variables of callers
localmake "L3 5 ; locally override L3 from caller
(print :y :L1 :L2 :L3) ; 4 6 9 5
end
print :g4 ; 4
print :L1 ; L1 has no value
print name? "L1 ; false, L1 is not bound in the current scope
You may also check:How to resolve the algorithm XML/Input step by step in the Wren programming language
You may also check:How to resolve the algorithm Detect division by zero step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Sort using a custom comparator step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the Quackery programming language
You may also check:How to resolve the algorithm Array length step by step in the Beef programming language