28 posts
Location
Somewhere in Nowhere
Posted 30 November 2016 - 03:56 PM
this is just a thing i wrote in like 40 mins (with no idea what i was going to make, so i was brainstorming for like an hour),
i also wrote this when i had to go, so i cant add screens or anything, file is in desc
PASTEBIN URL: AaWnayNL
EDIT: this was also a little test for me to see if i could work with tables (never worked with them before, or at least not intensively) and i think it worked out pretty well.
Edited on 30 November 2016 - 05:00 PM
726 posts
Location
Rem is best girl
Posted 30 November 2016 - 04:12 PM
Sorry to say this, but cant you just do
shell.run("rm *")
:P/>
74 posts
Location
~
Posted 30 November 2016 - 05:46 PM
Spoiler
--CCFormat, made by lolmaker2002
print("THIS PROGRAM WILL COMPLETELY WIPE YOUR DRIVE!")
print("if this action is purposely done, press enter")
print("else, hold CTRL+T")
read()
for k, v in ipairs(fs.list("")) do
fs.delete(v)
end
Made it better
28 posts
Location
Somewhere in Nowhere
Posted 30 November 2016 - 05:52 PM
Spoiler
--CCFormat, made by lolmaker2002
print("THIS PROGRAM WILL COMPLETELY WIPE YOUR DRIVE!")
print("if this action is purposely done, press enter")
print("else, hold CTRL+T")
read()
for k, v in ipairs(fs.list("")) do
fs.delete(v)
end
Made it better
thanks! i dont know how the for loop works, so i did the best i could, but if its ok ill use this instead of mine.
EDIT: i've been using computercraft for a long while now but i still dont get half of it, i usually just get lucky with my programs and just roll with it.
Edited on 30 November 2016 - 04:53 PM
28 posts
Location
Somewhere in Nowhere
Posted 30 November 2016 - 06:02 PM
Sorry to say this, but cant you just do
shell.run("rm *")
:P/>
thats true actually, but my goal was to make it so it doesn't remove the file its being executed from, and also to learn how to work with tables.
463 posts
Location
Star Wars
Posted 06 December 2016 - 03:59 PM
For loops are very important in Lua.
4 posts
Posted 13 December 2016 - 08:25 PM
For loops are very important in Lua.
In every programming language. *
1426 posts
Location
Does anyone put something serious here?
Posted 14 December 2016 - 07:33 AM
For loops are very important in Lua.
In every programming language. *
Not
every language. You'd use recursion in functional programming languages instead.
Edited on 14 December 2016 - 12:10 PM
463 posts
Location
Star Wars
Posted 04 March 2017 - 07:25 PM
For loops are very important in Lua.
In every programming language. *
Not
every language. You'd use recursion in functional programming languages instead.
Give an example please.
1426 posts
Location
Does anyone put something serious here?
Posted 04 March 2017 - 07:33 PM
Not every language. You'd use recursion in functional programming languages instead.
Give an example please.
For a simple for loop, you could have something like this:
local function printTimes(count, string)
if count <= 0 then
return
else
print(string)
return printTimes(count - 1)
end
end
printTimes(10, "Hello")
This will print the string "Hello" 10 times. This is actually how all loops are implemented in Urn behind the scenes.
463 posts
Location
Star Wars
Posted 04 March 2017 - 10:40 PM
Not every language. You'd use recursion in functional programming languages instead.
Give an example please.
For a simple for loop, you could have something like this:
local function printTimes(count, string)
if count <= 0 then
return
else
print(string)
return printTimes(count - 1)
end
end
printTimes(10, "Hello")
This will print the string "Hello" 10 times. This is actually how all loops are implemented in Urn behind the scenes.
And which programming languages don't support for loops?
1426 posts
Location
Does anyone put something serious here?
Posted 04 March 2017 - 10:50 PM
And which programming languages don't support for loops?
Haskell would be the first to spring to mind: there are no looping constructs at all - you do everything with recursion. Most Lisps won't have loops as part of the core language: they'll be implemented through tail recursion. Generally, a lot of
functional programming languages don't have them.