How to resolve the algorithm Box the compass step by step in the Lasso programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Box the compass step by step in the Lasso programming language

Table of Contents

Problem Statement

There be many a land lubber that knows naught of the pirate ways and gives direction by degree! They know not how to box the compass!

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Box the compass step by step in the Lasso programming language

Source code in the lasso programming language

define pointsarray() => {
	local(points = array)
	loop(-from=0,-to=32) => {
		local(heading = loop_count * 11.25)
		if(loop_count % 3 == 1) => {
			#heading += 5.62
		else(loop_count % 3 == 2)
			#heading -= 5.62
		}
		#points->insert(#heading)
	}
	return #points
}
define compassShort => array(
	'N','Nbe','N-ne','Nebn','Ne','Nebe','E-ne','Ebn',
	'E','Ebs','E-se','Sebe','Se','Sebs','S-se','Sbe',
	'S','Sbw','S-sw','Swbs','Sw','Swbw','W-sw','Wbs',
	'W','Wbn','W-nw','Nwbw','Nw','Nwbn','N-nw','Nbw', 'N')
define compassLong(short::string) => {
	local(o = string)
	with i in #short->values do => { #o->append(compassLongProcessor(#i)) }
	return #o
}
define compassLongProcessor(char::string) => {
	#char == 'N' ? return #char + 'orth'
	#char == 'S' ? return #char + 'outh'
	#char == 'E' ? return #char + 'ast'
	#char == 'W' ? return #char + 'est'
	#char == 'b' ? return ' by '
	#char == '-' ? return '-'	
}
// test output points as decimals
//pointsarray

// test output the array of text values
//compassShort

// test output the long names of the text values
//with s in compassShort do => {^ compassLong(#s) + '\r' ^}

'angle  | box  | compass point
---------------------------------
'
local(counter = 0)
with p in pointsarray do => {^
	local(pformatted = #p->asString(-precision=2))
	while(#pformatted->size < 6) => { #pformatted->append(' ') }
	#counter += 1
	#counter > 32 ? #counter = 1
	#pformatted + ' |  ' + (#counter < 10 ? ' ') + #counter + '  | ' + compassLong(compassShort->get(#counter)) + '\r'
	
^}


  

You may also check:How to resolve the algorithm Van Eck sequence step by step in the Haskell programming language
You may also check:How to resolve the algorithm Bin given limits step by step in the Tcl programming language
You may also check:How to resolve the algorithm Zig-zag matrix step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Compound data type step by step in the Clean programming language
You may also check:How to resolve the algorithm Check that file exists step by step in the Scheme programming language