How to resolve the algorithm Take notes on the command line step by step in the Lasso programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Take notes on the command line step by step in the Lasso programming language
Table of Contents
Problem Statement
Invoking NOTES without commandline arguments displays the current contents of the local NOTES.TXT if it exists. If NOTES has arguments, the current date and time are appended to the local NOTES.TXT followed by a newline. Then all the arguments, joined with spaces, prepended with a tab, and appended with a trailing newline, are written to NOTES.TXT. If NOTES.TXT doesn't already exist in the current directory then a new NOTES.TXT file should be created.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Take notes on the command line step by step in the Lasso programming language
Source code in the lasso programming language
#!/usr/bin/lasso9
local(
arguments = $argv -> asarray,
notesfile = file('notes.txt')
)
#arguments -> removefirst
if(#arguments -> size) => {
#notesfile -> openappend
#notesfile -> dowithclose => {
#notesfile -> writestring(date -> format(`YYYY-MM-dd HH:mm:SS`) + '\n')
#notesfile -> writestring('\t' + #arguments -> join(', ') + '\n')
}
else
#notesfile -> exists ? stdout(#notesfile -> readstring)
}
./notes "Rosetta was here" Räksmörgås
./notes First Second Last
./notes
You may also check:How to resolve the algorithm List comprehensions step by step in the Stata programming language
You may also check:How to resolve the algorithm Combinations with repetitions step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Count the coins step by step in the Maple programming language
You may also check:How to resolve the algorithm Runge-Kutta method step by step in the Java programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bead sort step by step in the C programming language