Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 519 520 [521] 522 523 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907970 times)

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7800 on: September 11, 2015, 12:54:51 pm »

Oh, apparently gedit has plugins and automatic tabulation. That's all I really need for small school assignments. Of course, my next assignment is supposed to be written inside XV6, so I'll probably just have to use vim anyway.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7801 on: September 11, 2015, 02:02:36 pm »

The automatic tabbing plugin is one I couldn't get to work right, incidentally.  That actually was probably the biggest headache I had to switching to gedit from other editors.  It took a while to get used to it not tabbing out automatically, and then when I changed editors when I went home... inverse problem.

Or maybe it just didn't support tabbing with tabs?  I'm one of those terrible people that uses tabs for tabs.
Logged
Through pain, I find wisdom.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7802 on: September 11, 2015, 05:10:26 pm »

I'm one of those terrible people that uses tabs for tabs.
4 spaces master race.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7803 on: September 11, 2015, 05:23:22 pm »

Yeah, I absolutely adore notepad++.
Once I wanted to use a regex on a text file, never having done this before, and /i just entered it into the replace function and checked the box labeled "regex"/.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7804 on: September 12, 2015, 12:26:18 am »

Yeah, I absolutely adore notepad++.
Once I wanted to use a regex on a text file, never having done this before, and /i just entered it into the replace function and checked the box labeled "regex"/.
Yep, and in an actual job with actual massive codebases, its 'find in files' is amazing. Fast enough to be used in a practical manner on entire engines and build systems (is it in a c or cpp or cs file? search in file *.c* over the entire engine directory and you get it quick), and best of all, it keeps a log of the recently searched files, so you can go back if you need to; and since its chronological, you can even retrace your steps of reasoning. Visual Studio doesn't even come close, with its mere two find windows for remembering output while needing to be explicitly directed there to use more than one.
Logged

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7805 on: September 13, 2015, 11:17:50 pm »

npp is an amazing little tool. The fact that it ships with an auto-completer that already contains the majority of c/c++ standard library functions is amazing.

I'm unsure if said plugin can trace functions through the list of includes, but I'm sure that wouldn't be so hard to write up myself if it doesn't.

And then it was the best editor.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7806 on: September 14, 2015, 08:51:14 am »

Behold, my mighty creation!

def factors(n):
    return sorted(list(set(reduce(lambda x,y: x+y, [x for x in map(lambda x: (x, n//x), [i for i in range(1, math.ceil(math.sqrt(n+1))) if n % i == 0])]))))


The reason I wrote this abomination is because a classmate really wanted to have a one-line factorization code, and I was curious if I could do it myself so... through much abuse of the concept of functional coding (mine isn't very functional if you get my gist), I've created the above code that works pretty well. It implements the sqrt(n) optimization for finding factors. which was basically all of the difficulty.

Moral of the story: when you can split it into three lines of code, do it.:P
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7807 on: September 14, 2015, 10:33:02 am »

this abomination


eh, programming world has seen worse.

http://rosettacode.org/wiki/Compile-time_calculation#C.2B.2B

in c++ you can have the compiler factorise numbers

(yes I know that's factorial and not factorisation)
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7808 on: September 14, 2015, 01:52:05 pm »

Looked at that site, stumbled over Perl 6, looked it up, and holy shit it's powerful. Perl 5 is already very powerful and concise, but Perl 6 takes the cake and also every other confectionery, and they're still not done adding features after 15 years of development.

So I've been using Perl 5 extensively and reading Perl 5 books for ten years now, and I'm now an expert on all things Perl 5 (of which there are lots). This includes being able to read Perl 5 well, because apparently Perl 5 is hard to read for people who haven't done a lot of it. But Perl 6, that's a whole new shipment of alphabet soup. Perl 6 has every single feature you could possibly imagine in a programming language, and if it doesn't have a feature, then it has a feature to let you add that feature in three lines of code or fewer.

Dynamic typing more dynamic than Python? Check. Static typing more versatile than C++? Check. Macros more useful than C? Check. Functional programming tighter than Haskell? Check. Concurrency prettier than Go? Check. Regexes more powerful than you could possibly imagine? Also check, of course. Inverse eval function? Dozens of awesome standard types and collections? Hundreds of operators? Meta operators? Custom operators? Logical superpositions of arbitrary values? Check, because this is the most ambitious programming language ever and it would be horrible if you couldn't do absolutely everything in less than 80 characters.
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7809 on: September 14, 2015, 02:06:28 pm »

To be completely honest, that looks absolutely horrible.

Also
Quote
Macros more useful than C? Check.
Programming easier than in Brainfuck? Check. :P
Logged
Taste my Paci-Fist

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7810 on: September 14, 2015, 02:33:56 pm »

To be completely honest, that looks absolutely horrible.
Compromises have to be made somewhere, but these guys figured out that they could keep everything else if they just sacrificed legibility. Perl 6 is nothing less than the Dwarf Fortress of programming languages.
Logged

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7811 on: September 14, 2015, 03:15:54 pm »

Machine code is also very powerful :P

Now I feel like I should learn Perl, though.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7812 on: September 14, 2015, 05:34:55 pm »

Dynamic typing more dynamic than Python?
Wait, is that even possible?

And if it is, why would you want that?
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7813 on: September 14, 2015, 07:00:10 pm »

Dynamic typing more dynamic than Python?
Wait, is that even possible?
Perl 5 already provides an incredibly dynamic approach to classes and objects: There are three main types of containers: scalars, arrays, and hash maps. Scalars hold a single thing, arrays hold a list of things indexed by position, and hash maps hold a list of things indexed by string. A thing can be a string, a number, or a reference to another container (among other things). Now Perl 5 has a feature called "blessing". Syntax: bless $refToContainer, "MyClass";. What this does is tell the container that it is now an object of the type MyClass, and that it should behave like MyClass says when it is treated like an object.

So when you write $refToContainer->foo(3), the MyClass namespace is searched for a function called foo, and if it's found, it's called with $refToContainer as its first argument and 3 as the second. If foo isn't found, then the super namespaces of MyClass are traversed recursively for foo (multiple inheritance and mixins are done simply by giving a namespace multiple super namespaces). If foo still isn't found, a special function called AUTOLOAD is called with the parameters $refToContainer, "foo" and 3, AUTOLOAD can be defined in MyClass or in its super classes, it's mainly used for autodelegation.

So basically, everything is duck typed, and objects are just of a certain type because they think they are. As you can see, this is already waaaay more dynamic than Python.

Perl 6 has an entirely different object system, a more sensible one with proper objects with attributes and methods and stuff, but it seems at least equally powerful. There's an important concept of roles, which are like interfaces but better, but I'm still reading through all those things. For example there's a built-in binary 'but' operator that allows you to do mixins per-object at runtime: If you say $thing = $car but $duck; then $thing is the same identical car as $car and $thing.drive() will have the same effect on $car as $car.drive(), but when you go $thing.speak() instead of $car.speak(), the car will go quack instead of honk.

Quote
And if it is, why would you want that?
I'm sure you can think of a lot of applications for only that 'but' operator. In any case, having an option is always better than having no option, because one day you'll be lazy enough to be glad you have that option. Also one of Perl's mottos is "There's more than one way to do it".
« Last Edit: September 14, 2015, 07:02:54 pm by MagmaMcFry »
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7814 on: September 14, 2015, 07:03:27 pm »

Sounds pretty neat, though I'm going to take offense at the fact that they called their keyword "bless". Honestly I think something like "imbue" or just a basic "cast" would probably a lot more understandable and wouldn't carry that same "we are a god!" connotations. :P
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.
Pages: 1 ... 519 520 [521] 522 523 ... 796