Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Plorkyeran posted:

"Most" is a bit of an understatement. A short-circuiting bitwise operator would be like short-circuiting multiplication.

You could do it if the first operand were 0, mind you (assuming it's not floating-point, of course). That would work for multiplication and bitwise AND, I believe. The all-1s case would be the equivalent for bitwise OR.

Whether it's useful or wise to do this is another matter altogether.

EDIT: Not division, since 0/0 could occur even in integer division.

PT6A fucked around with this message at 05:23 on Apr 16, 2010

Adbot
ADBOT LOVES YOU

Nippashish
Nov 2, 2005

Let me see you dance!
In Java | and & are the non-short-circuiting versions of || and &&.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Nippashish posted:

In Java | and & are the non-short-circuiting versions of || and &&.
Compare 1 && 2 and 1 & 2.

Nippashish
Nov 2, 2005

Let me see you dance!

Plorkyeran posted:

Compare 1 && 2 and 1 & 2.

They're also bitwise operators when the operands are integral types. Maybe you should try them with boolean operands.

shrughes
Oct 11, 2008

(call/cc call/cc)

Nippashish posted:

In Java | and & are the non-short-circuiting versions of || and &&.

The same behavior is exhibited in, like, every language, not just Java. So I don't get what you're getting at.

Nippashish posted:

They're also bitwise operators when the operands are integral types. Maybe you should try them with boolean operands.

They're bitwise operators for boolean types in Java too.

yatagan
Aug 31, 2009

by Ozma
Help what is boolean logic it is very confusing to me with all those 1's and 0's.

Pantsmaster Bill
May 7, 2007

How would I create a function that prints its own definition? I've been given the problem in Haskell, but I can't figure how I would do it in any language, short of opening the file and printing from there.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Nippashish posted:

They're also bitwise operators when the operands are integral types. Maybe you should try them with boolean operands.
In many languages you often happen to be able to use + and * as non-short-circuiting versions of || and &&, but that doesn't make describing + and * as such in any way sane.

csammis
Aug 26, 2003

Mental Institution

Pantsmaster Bill posted:

How would I create a function that prints its own definition? I've been given the problem in Haskell, but I can't figure how I would do it in any language, short of opening the file and printing from there.

What you're looking for is a quine

bitprophet
Jul 22, 2004
Taco Defender

Pantsmaster Bill posted:

How would I create a function that prints its own definition? I've been given the problem in Haskell, but I can't figure how I would do it in any language, short of opening the file and printing from there.

Depends very much on the language's implementation, both in terms of whether it's even possible, and in terms of the specific methodology you'd use to obtain the source code.

Here's a Python example, though it only appears to work if defined in an actual on-disk file -- won't work in the interpreter. I assume this is because it's actually reading the file to get the source; this ain't exactly something one does in daily coding (unless you work in Lisp a lot I guess) v:shobon:v
code:
import inspect

def foo():
    print inspect.getsource(foo)

foo()

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

bitprophet posted:

Depends very much on the language's implementation, both in terms of whether it's even possible, and in terms of the specific methodology you'd use to obtain the source code.

Here's a Python example, though it only appears to work if defined in an actual on-disk file -- won't work in the interpreter. I assume this is because it's actually reading the file to get the source; this ain't exactly something one does in daily coding (unless you work in Lisp a lot I guess) v:shobon:v
code:
import inspect

def foo():
    print inspect.getsource(foo)

foo()

This is the lame cop out way. You want a quine like csammis suggested.

Montalvo
Sep 3, 2007



Fun Shoe
edit: nvm, got it!

Montalvo fucked around with this message at 18:08 on Apr 16, 2010

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have a hashing question that first came up in the C++ programming thread, but after thinking about it I think this is a general problem. I was using boost's unordered_map to do a ton of hashing it is a lot slower than the Java equivalent from which I was porting as an experiment. I ran gprof on it and got a huge templated mess that I posted in the C++ thread, but after a day I think I sorted it out.

It looks like 50% of the run time is split between rearrange items in buckets and my equals operator. Does this imply I'm having a ton of hash collisions? I increased the default bucket size to about 1.25x the final number of entries I would store and it still ran rear end slow.

I looked at my hash code output for some example data and originally it was kind of bad. Say, it would look something like:

849000xxxxxx

Where the last few digits were the only thing really changing. I modified the hashing routine so that from increment to increment all sides appears to be the same. I suppose I could do a scatter plot of some sample data to see if it groups in places. Anyways I updated that and it still ran slow. :( WTH...

MononcQc
May 29, 2007

Pantsmaster Bill posted:

How would I create a function that prints its own definition? I've been given the problem in Haskell, but I can't figure how I would do it in any language, short of opening the file and printing from there.

The easy way out I used to write a quine (as pointed by csammis) was usually some play on printf-like function. Basically, you have the function that can take a string representation of itself twice as argument and then output it.

Here's the Erlang version I had written for rosettacode

E: removed for breaking tables. See http://rosettacode.org/wiki/Quine#Erlang

Here the list of integers is actually a string to Erlang. The first ~s interprets the list as a string and ~w interprets it as a list. In languages that do not require the whole module structure Erlang needs, quines can actually get much shorter because you can basically just print the argument string into itself.

There are differences in every languages depending on different string representations or concepts like homoiconicity, but the basic easy way is always to have a function printing a string representation of itself + the string.

E: sorry for table breakage and also csammis' link had it all explained. Here, have a quine page: http://rosettacode.org/wiki/Quine instead to make this post more worthy

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Rocko Bonaparte posted:

It looks like 50% of the run time is split between rearrange items in buckets and my equals operator. Does this imply I'm having a ton of hash collisions?
Yes. Post your hash function.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Mustach posted:

Yes. Post your hash function.

I will send it through pastebin so I can attach on an example of how it hashes a year worth of dates w/o a wall of text:

http://pastebin.com/V5v3diSj

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Rocko Bonaparte posted:

I will send it through pastebin so I can attach on an example of how it hashes a year worth of dates w/o a wall of text:

http://pastebin.com/V5v3diSj

The amount of collisions you have in that hash is absolutely ridiculous (to the point that I saw a few before I even sorted the lines by hash). You have a total of 42 unique hashes in that entire list.

EDIT: first things first, I'm going to assume that you think a + b << c == a + (b << c). It doesn't, in general. + has higher precedence than <<.
EDITx2: Oh wow. When you take the modulo of that with just about any reasonably-sized power of 2, they all fall in the same bucket. So basically you might as well have just written "return 0;"

Avenging Dentist fucked around with this message at 01:58 on Apr 17, 2010

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Avenging Dentist posted:

The amount of collisions you have in that hash is absolutely ridiculous (to the point that I saw a few before I even sorted the lines by hash). You have a total of 42 unique hashes in that entire list.

EDIT: first things first, I'm going to assume that you think a + b << c == a + (b << c). It doesn't, in general. + has higher precedence than <<.
EDITx2: Oh wow. When you take the modulo of that with just about any reasonably-sized power of 2, they all fall in the same bucket. So basically you might as well have just written "return 0;"
Hmm I guess I should call CERN because I just invented a supercollider. :lol:

Yes I had my order of operations wrong on the shift operators.

I'll just work on the hash code for a little bit before getting into anything more fancy.

Boost's method for handling dates and times is really starting to annoy the hell out of me. I wrote that code as a first attempt at trying to make something from what the API could give me. You'd think they had made hash operators for the objects they support. I suppose if I get it worked out I should send something off to boost. Since I first looked into it I found it can give me a julian date which I think is how the days are stored internally, so I think I'll just smash that with the time of day in nanoseconds and then try some things to make it collide less.

Scaevolus
Apr 16, 2007

Rocko Bonaparte posted:

I found it can give me a julian date which I think is how the days are stored internally, so I think I'll just smash that with the time of day in nanoseconds and then try some things to make it collide less.
Why not just take the seconds since the epoch plus the time of day in nanoseconds?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Scaevolus posted:

Why not just take the seconds since the epoch plus the time of day in nanoseconds?
yes that's basically what I changed to. I don't even think the resulting number needs to necessarily go through an additional hashing step. I printed out the hash codes and checked the modulus for them for the numbers 16 (power of 2), 7 (prime), and 535 (generally optimal size of target set for 1:1 mapping). It looked good so I switched to it. Things sped up a little but I see it's still trying to copy buckets. Interestingly enough the equality operator no longer shows up in the profile though. So I think now I probably am doing something stupid in the hashing; I'm switching back over to running Ubuntu so I can run some more understandable profiling tools to figure out which instructions are triggering the buckets moving around. Chances are I have some stupid pointer crap going on someplace.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

Why not just take the seconds since the epoch plus the time of day in nanoseconds?

Unless he's actually likely to have keys whose only difference is in nanoseconds, this is unnecessary and would probably just increase the chance of collisions. Since he appears to be using 64-bit values, he has enough space to have a unique hash for every 23 milliseconds since the beginning of the universe. He could just store the number of microseconds since some minimum date and be fine. Also this method has the benefit of making sure that relatively nearby times won't be congruent modulo N for most N (i.e. they won't fall into the same buckets).

Also Rocko, if by "an additional hashing step", you're referring to the fact that you hash the integers you get from the date and time, that does literally nothing (at basically zero performance cost) since boost's hash function for integral values is the identity function.

Avenging Dentist fucked around with this message at 23:43 on Apr 17, 2010

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Avenging Dentist posted:

Also Rocko, if by "an additional hashing step", you're referring to the fact that you hash the integers you get from the date and time, that does literally nothing (at basically zero performance cost) since boost's hash function for integral values is the identity function.
Yes I was taking a hash of the number of days since epoch and the hash of the number of nanoseconds of a day, and adding those hashes together. Didn't do anything and dismissed it without really asking why.

Since I'm writing my own, I could probably make use of the fact that the dates I'm dealing with will probably only span back to the last decade. However, right now I'm not seeing much of a collision problem anymore so I'm letting that be.

I got my old Ubuntu setup working again and I think I want to try the slew of profiling tools that I can finally run (curse gentoo and it's qt4 zealotry among other things).

As you said boost's foreach is the devil and I'm curious if in using it I'm incurring some nasty overhead. If I can start pegging events to locations in the code I think I'll know better what's really happening.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Rocko Bonaparte posted:

As you said boost's foreach is the devil and I'm curious if in using it I'm incurring some nasty overhead. If I can start pegging events to locations in the code I think I'll know better what's really happening.

Performance should be pretty close if not the same when you optimize, but there's a lot happening under the hood.

TheGopher
Sep 7, 2009
So I did some really good tutorials that taught me a ton (link), but the guy who wrote them is working on other things and there won't be more lessons for quite awhile. I have a good grasp of what's going on with programming, but I can't find any good resources to help me push forward and teach myself more because either what I'm reading is:

A) Too Technical
B) Poorly written and not thorough at explaining concepts
C) Just plain terrible

I'm sure you've read books like what's above, or online tutorials. I really just cannot find anything good.

I have a clear goal of what I want to be doing with programming in the near future: Making a HL2 mod (I have friends who want to learn with me, except they're doing art). Obviously there is a lot of work in between programming a very complicated game engine like that and where I'm at making dos applications, but I really don't know where to start. I just want a resource that can explain what I need to learn effectively without trying to be too technical, or not technical enough (as in merely teaching syntax and not explaining). I'm open to any kind of learning process with a relatively low barrier of entry (i.e. doesn't cost thousands of dollars)

If anybody's been in a similar situation and is now doing some more high-end programming, I'd be very interested to know how you got to where you are now.

shrughes
Oct 11, 2008

(call/cc call/cc)

TheGopher posted:

So I did some really good tutorials that taught me a ton (link), but

So you wait, what? What are you talking about? So you're reading tutorials. Doing them. Okay. Tutorials about what? Okay, tutorials written by a redditor. Ugh.

TheGopher posted:

the guy who wrote them is working on other things and there won't be more lessons for quite awhile. I have a good grasp of what's going on with programming, but I can't find any good resources to help me push forward and teach myself more because either what I'm reading is:

Hold on, what the hell. You haven't told us what you know, who you are, what you know, or what you know. How much do you know about programming? You have a good grasp of what's going on with programming? What does that even mean? I have no idea whether you could write a C++ compiler in your sleep or whether you'd have trouble writing the simplest of XML scrapers.

TheGopher posted:

A) Too Technical

How can something be too technical? Programming is a technical subject, is it not? Does the thing-that-is-too-technical assume knowledge you don't have? If so, you can get that knowledge, and so it's not too technical. If not, then it's not too technical.

TheGopher posted:

B) Poorly written and not thorough at explaining concepts

Show me something (other than CarlH's stuff) that's poorly written and not thorough. Maybe you're dumb and lazy. (Maybe you're not, I'm not saying you are, and I'm not even "asking" in the Fox News sense -- it's just that I don't know you.)

TheGopher posted:

C) Just plain terrible

Yeah, there are a lot of these. But communication is a double-ended process so you can't go blaming the authors without blaming yourself.

quote:

I'm sure you've read books like what's above, or online tutorials. I really just cannot find anything good.

You want to learn programming? Start by reading The Python Tutorial. How much do you know. Is that too beginner for you? I don't know.

TheGopher posted:

I have a clear goal of what I want to be doing with programming in the near future: Making a HL2 mod (I have friends who want to learn with me, except they're doing art). Obviously there is a lot of work in between programming

Yeah, there's a lot of work, and a lot of what-do-I-do-next. You start by asking "how do I make an HL2 mod?" And then you type that into google. Maybe you'll get some clues on some game dev forum. Maybe you'll find an open source HL2 mod. Then you go and look at that code. See how it works. Modify it. Fiddle with it. Never once should you say, "I don't get this" and stop, because that's loving retarded. If you don't get it (and there are lots of times when you don't) you just need to ask yourself what information you need in order to get it. If you can't find that information, you need to figure out the information yourself, experimentally.

TheGopher posted:

a very complicated game engine like that and where I'm at making dos applications, but I really don't know where to start. I just want a resource that can explain what I need to learn effectively without trying to be too technical, or not technical enough (as in merely teaching syntax and not explaining). I'm open to any kind of learning process with a relatively low barrier of entry (i.e. doesn't cost thousands of dollars)

If you want to make an HL2 mod, the barriers to entry are high and numerous. Deal with it.

TheGopher
Sep 7, 2009

shrughes posted:

multiquote reply that makes the post difficult to address

CarlH (the author of those tutorials) wrote some pretty comprehensive information about programming. Maybe you could have taken 1 minute to click on the link and look at the most recently published lessons (which were from awhile ago) to see what I've been learning. The fact you'll bash him just because he's a Redditor without even reading what he's written really says a lot. (Maybe you have read his stuff, you didn't make that clear, in which case, please explain why I'm wrong about his writing being good)

I know basic C concepts. Stuff like pointers, arrays, defining classes, typecasting, etc. Basic stuff. I have no idea where to go from here. To be clear, C is the only language I'm familiar with. I could probably get to the same point with another language with minimal effort because I really understand what I've been taught.

The resources I've looked at read like a 5th grader's explanation of fractions, or read like any unix "man" entry. That is what I meant by "too technical" or "poorly written". I want something in between, something I can follow with a reasonable amount of effort.

In terms of HL2 mods, I'm going through the Valve developer wiki, which is poo poo because most of the info on there is out of date and vague. I had to bash my head trying to get VSE2010's debugger to launch properly because of the complete lack of documentation. I figured out how to modify existing entities to the game and how the game revolves around them. I can figure out things on my own, I just need a better knowledge of C/C++ because I don't know what half of the functions I'm looking at are trying to accomplish or why they're needed. I've done a good amount of searching but there doesn't seem to be any good starting point for a new programmer trying to work with HL2.

Let me put it this way, I can probably do problems 1-10 of project Euler, but after that I'm pretty much lost. How do I learn the programming methodology to progress further?

TheGopher fucked around with this message at 01:35 on Apr 19, 2010

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

TheGopher posted:

CarlH (the author of those tutorials) wrote some pretty comprehensive information about programming. Maybe you could have taken 1 minute to click on the link and look at the most recently published lessons (which were from awhile ago) to see what I've been learning.

You are the one asking for help. It is not shrughes' responsibility to try to decipher what it is you've learned.

TheGopher posted:

The fact you'll bash him just because he's a Redditor without even reading what he's written really says a lot.

I skimmed over his tutorials and, lo and behold, it looks like shrughes' skepticism was totally merited. Teaching gotos before conditionals? Check. Asserting that arrays are pointers? Check. Asserting that all non-primitives are pointers? Ch-- wait what?? :psyduck:

For those playing the home game:

Reddit Idiot posted:

As I stated in an earlier lesson, any time you are working with any type of data more complex than a single variable of a given data type, you are working with a pointer.

Granted, this is probably just lovely phrasing, but why would you read a tutorial with such lovely phrasing to begin with?

TheGopher posted:

I know basic C concepts. Stuff like pointers, arrays, defining classes, typecasting, etc.

https://www.youtube.com/watch?v=0WhuikFY1Pg

TheGopher posted:

The resources I've looked at read like a 5th grader's explanation of fractions, or read like any unix "man" entry. That is what I meant by "too technical" or "poorly written". I want something in between, something I can follow with a reasonable amount of effort.

Let me put it this way, I can probably do problems 1-10 of project Euler, but after that I'm pretty much lost. How do I learn the programming methodology to progress further?

Go program. (This is the serious part of my post. Listen to it.)

Avenging Dentist fucked around with this message at 01:51 on Apr 19, 2010

shrughes
Oct 11, 2008

(call/cc call/cc)

TheGopher posted:

I know basic C concepts. Stuff like pointers, arrays, defining classes, typecasting, etc. Basic stuff. I have no idea where to go from here. To be clear, C is the only language I'm familiar with. I could probably get to the same point with another language with minimal effort because I really understand what I've been taught.

...

Let me put it this way, I can probably do problems 1-10 of project Euler, but after that I'm pretty much lost. How do I learn the programming methodology to progress further?

Okay. If I asked you to make a stack datatype in C, would you be able to do it? How about a binary search tree?

I don't know what you mean by methodology, but it seems to me like it would be inefficient to continue progressing only knowing C. I'm not sure whether to say, "Learn C++, and go with that for a while," or to say "Learn Python, and go with that for a while." I think right now you need some general experience in two areas: dealing with data structures, and writing useful programs that don't just talk on standard I/O. I get the feeling that Python will be quicker to learn and get you there faster, and when you go to C++ later, you'll progress through it more quickly. That's because there are far fewer landmines in Python than in C++. I feel it's better to learn C++ in the context of knowledge and experience that one would have, having used garbage collected, dynamically typed languages, such as Python.

TheGopher
Sep 7, 2009

Avenging Dentist posted:

troll post

So all I got out of your post is:

A) The lessons I went through are lovely
B) I didn't explain myself properly, and I should have
C) Explaining myself warrants a sesame st. video to boost your ego because you think I'm being self-congratulatory
D) Programming more will solve my problems.

If I'm learning from a lovely resource, how is doing more programming going to teach me to be a better programmer? While you're getting off on being so smart and being such a great programmer maybe you could actually help me instead of trying to troll me out of this topic for not knowing enough.

Between those two posts, all I've found out is that I'm doing it wrong and I should go bash my head against a concrete wall until I figure it out. I thought the point of this topic was to ask questions and get answers and not get trolled to hell and back.

TheGopher
Sep 7, 2009

shrughes posted:

Okay. If I asked you to make a stack datatype in C, would you be able to do it? How about a binary search tree?

I don't know what you mean by methodology, but it seems to me like it would be inefficient to continue progressing only knowing C. I'm not sure whether to say, "Learn C++, and go with that for a while," or to say "Learn Python, and go with that for a while." I think right now you need some general experience in two areas: dealing with data structures, and writing useful programs that don't just talk on standard I/O. I get the feeling that Python will be quicker to learn and get you there faster, and when you go to C++ later, you'll progress through it more quickly. That's because there are far fewer landmines in Python than in C++. I feel it's better to learn C++ in the context of knowledge and experience that one would have, having used garbage collected, dynamically typed languages, such as Python.

Yeah I have no idea how do do either of those first two things.

So if Python is a good starting point, what lessons or site do you recommend I use to get the most out of my time investment?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

So, I think it's worth pointing out that "I want to become better at programming" is pretty much orthogonal to "what do I need to do to be able to make a mod". Growing up, I was in the latter camp, and never really enjoyed programming because I always bit off far more than I could ever chew, and only in order to serve some end rather than for the pleasure of actually doing it.

Having trouble with VS2010's debugger? Play around with it! You'll learn a hell of a lot in the process. Is some piece of documentation too dense? Take a step back, branch off and figure out what it's talking about one unfamiliar term at a time. These digressions (which may send you off off a totally different adventure) are how you get stronger.

TheGopher posted:

The fact you'll bash him just because he's a Redditor without even reading what he's written really says a lot.
Also, consider this post Dijkstracula's biweekly "proggit is a wasteland of circlejerking and terrible information sprinkled with the occasional good article, and anything that originates with that community is likely to suck hard" rant.

edit: also, a valuable CoC guideline is "AD can be blunt but he's often right, so it's best to listen to what he says instead of summarily rejecting it because he doesn't mince words".

Dijkstracula fucked around with this message at 02:04 on Apr 19, 2010

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

TheGopher posted:

If I'm learning from a lovely resource, how is doing more programming going to teach me to be a better programmer? While you're getting off on being so smart and being such a great programmer maybe you could actually help me instead of trying to troll me out of this topic for not knowing enough.

Do you want to know how I and nearly everyone in this subforum learned to program? We programmed. Period. There's no magic elixir, no spellbook that just grants you the skills derived from actual experience. Stop expecting that something like this exists. By the time you know enough to benefit from halfway decent resources you will already know where they are.

Go. Figure out some stuff you want to program. Try to do it. Fail. Learn from your failures. Repeat. Programming is hard work, but the process by which you learn is not complicated.

shrughes
Oct 11, 2008

(call/cc call/cc)
Edit: Just listen to what AD said. I've decided to start trolling you instead of being helpful.



TheGopher posted:

So all I got out of your post is:

A) The lessons I went through are lovely

They are. I remember when he first decided to make that subreddit. He didn't know anything. It's a noob trying to write a programming tutorial, with no perspective of what's important. And so it goes.

quote:

B) I didn't explain myself properly, and I should have
Yup :)

quote:

C) Explaining myself warrants a sesame st. video to boost your ego because you think I'm being self-congratulatory

You said "defining classes." There's no such thing as classes in C. Hence the cookie monster song.

quote:

D) Programming more will solve my problems.

That's right. You get better at programming by programming more.

quote:

If I'm learning from a lovely resource, how is doing more programming going to teach me to be a better programmer?

Experience.

quote:

While you're getting off on being so smart and being such a great programmer maybe you could actually help me instead of trying to troll me out of this topic for not knowing enough.

He's not trolling.

quote:

Between those two posts, all I've found out is that I'm doing it wrong and I should go bash my head against a concrete wall until I figure it out.

That's pretty much how learning works. If you want to know X, find something that explains X. If it doesn't make sense, it's because it uses information you don't understand. So ask what you don't understand, and then learn that. If you want to learn about a whole general topic, there's the problem of known unknowns versus unknown unknowns. The problem with CarlH's tutorials are the unknown unknowns that CarlH is basically ignorant of. Guides that walk you through things are helpful for the unknown unknowns, and reference documentation will help you with the known unknowns.

Here's the man page for strlen. What is too technical about this manpage?

code:
STRLEN(3)                BSD Library Functions Manual                STRLEN(3)

NAME
     strlen -- find length of string

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <string.h>

     size_t
     strlen(const char *s);

DESCRIPTION
     The strlen() function computes the length of the string s.

RETURN VALUES
     The strlen() function returns the number of characters that precede
     the terminating NUL character.

SEE ALSO
     string(3)

STANDARDS
     The strlen() function conforms to ISO/IEC 9899:1990 (``ISO C90'').

BSD                              June 4, 1993                              BSD
Here's the man page for strcasecmp. What is too technical about that?

code:
STRCASECMP(3)            BSD Library Functions Manual            STRCASECMP(3)

NAME
     strcasecmp, strcasecmp_l, strncasecmp, strncasecmp_l -- compare
     strings, ignoring case

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <strings.h>

     int
     strcasecmp(const char *s1, const char *s2);

     int
     strncasecmp(const char *s1, const char *s2, size_t n);

     #include <strings.h>
     #include <xlocale.h>

     int
     strcasecmp_l(const char *s1, const char *s2, locale_t loc);

     int
     strncasecmp_l(const char *s1, const char *s2, size_t n,
         locale_t loc);

DESCRIPTION
     The strcasecmp() and strncasecmp() functions compare the null-termi-
     nated strings s1 and s2.

     The strncasecmp() compares at most n characters.

     Although the strcasecmp() and strncasecmp() functions use the current
     locale, the strcasecmp_l() and strncasecmp_l() functions may be
     passed locales directly. See xlocale(3) for more information.

RETURN VALUES
     The strcasecmp() and strncasecmp() return an integer greater than,
     equal to, or less than 0, according as s1 is lexicographically
     greater than, equal to, or less than s2 after translation of each
     corresponding character to lower-case.  The strings themselves are
     not modified.  The comparison is done using unsigned characters, so
     that `\200' is greater than `\0'.

SEE ALSO
     bcmp(3), memcmp(3), strcmp(3), strcoll(3), strxfrm(3), tolower(3),
     xlocale(3)

HISTORY
     The strcasecmp() and strncasecmp() functions first appeared in
     4.4BSD.  Their prototypes existed previously in <string.h> before
     they were moved to <strings.h> for IEEE Std 1003.1-2001 (``POSIX.1'')
     compliance.

BSD                              June 9, 1993                              BSD

quote:

I thought the point of this topic was to ask questions and get answers and not get trolled to hell and back.

Nobody's trolling you.

shrughes
Oct 11, 2008

(call/cc call/cc)

TheGopher posted:

So if Python is a good starting point, what lessons or site do you recommend I use to get the most out of my time investment?

http://python.org/download/

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Also, I've always had great help in the Python megathread/

(also also, let me reiterate that thinking about learning how to program in terms of "time investments" is going to ultimately leave you a bitter, twisted, unhappy person.)

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Here's what I learned from reading reddit for a couple of months: To stop reading reddit.

TheGopher
Sep 7, 2009

Mustach posted:

Here's what I learned from reading reddit for a couple of months: To stop reading reddit.

Sometimes being right isn't everything, otherwise I'd read SomethingAwful all the time.

mr_jim
Oct 30, 2006

OUT OF THE DARK

TheGopher posted:

Sometimes being right isn't everything, otherwise I'd read SomethingAwful all the time.

CoC doesn't help your ego, but it does help your programming. Have a thicker skin, you're getting some good advice here.

UberJumper
May 20, 2007
woop
Lets say i have a random set of 40->50 points x,y points. Distributed throughout the screen.

Is there an easy way to split this single group of points into two distinct node sets?

Adbot
ADBOT LOVES YOU

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

UberJumper posted:

Lets say i have a random set of 40->50 points x,y points. Distributed throughout the screen.

Is there an easy way to split this single group of points into two distinct node sets?

Yep. Declare node set A to be the set of all the points you have, and set B to be the empty set.

Edit: If it's not obvious, you need to better explain how you want to split the group, and consequently what problem you are actually trying to solve. Splitting a group of things into two groups of things is so trivial that you aren't likely to get a useful answer out of us without some more information.

ShoulderDaemon fucked around with this message at 05:47 on Apr 19, 2010

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply