Jump to content




CCFormat - A simple way to format your current computer


11 replies to this topic

#1 lolmaker2002

  • Members
  • 28 posts
  • LocationSomewhere 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 by lolmaker2002, 30 November 2016 - 06:00 PM.


#2 TheRockettek

  • Members
  • 547 posts
  • LocationRem is best girl

Posted 30 November 2016 - 04:12 PM

Sorry to say this, but cant you just do
shell.run("rm *")
:P

#3 AlexDevs

  • Members
  • 72 posts
  • Location~

Posted 30 November 2016 - 05:46 PM

Spoiler
Made it better

#4 lolmaker2002

  • Members
  • 28 posts
  • LocationSomewhere in Nowhere

Posted 30 November 2016 - 05:52 PM

 Ale32bit, on 30 November 2016 - 05:46 PM, said:

Spoiler
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 by lolmaker2002, 30 November 2016 - 05:53 PM.


#5 lolmaker2002

  • Members
  • 28 posts
  • LocationSomewhere in Nowhere

Posted 30 November 2016 - 06:02 PM

 TheRockettek, on 30 November 2016 - 04:12 PM, said:

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.

#6 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 06 December 2016 - 03:59 PM

For loops are very important in Lua.

#7 Tazkazz

  • Members
  • 4 posts

Posted 13 December 2016 - 08:25 PM

 Sewbacca, on 06 December 2016 - 03:59 PM, said:

For loops are very important in Lua.

In every programming language. *

#8 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 14 December 2016 - 07:33 AM

 Tazkazz, on 13 December 2016 - 08:25 PM, said:

 Sewbacca, on 06 December 2016 - 03:59 PM, said:

For loops are very important in Lua.
In every programming language. *
Not every language. You'd use recursion in functional programming languages instead.

Edited by SquidDev, 14 December 2016 - 01:10 PM.


#9 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 04 March 2017 - 07:25 PM

 SquidDev, on 14 December 2016 - 07:33 AM, said:

 Tazkazz, on 13 December 2016 - 08:25 PM, said:

 Sewbacca, on 06 December 2016 - 03:59 PM, said:

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.

#10 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 04 March 2017 - 07:33 PM

 Sewbacca, on 04 March 2017 - 07:25 PM, said:

 SquidDev, on 14 December 2016 - 07:33 AM, said:

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.

#11 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 04 March 2017 - 10:40 PM

 SquidDev, on 04 March 2017 - 07:33 PM, said:

 Sewbacca, on 04 March 2017 - 07:25 PM, said:

 SquidDev, on 14 December 2016 - 07:33 AM, said:

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?

#12 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 04 March 2017 - 10:50 PM

 Sewbacca, on 04 March 2017 - 10:40 PM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users