{{{#!IRC [Jun 21 16:53:38] juju2143, so hey, you ok if we schedule classes to start at #ubuntu-classroom this wednesday? [Jun 21 16:53:54] yep [Jun 21 16:54:00] I'll talk to them [Jun 21 16:54:05] how many weeks do you think you'll need? [Jun 21 17:02:27] juju2143, ^ [Jun 21 17:09:21] idk [Jun 21 18:09:45] juju2143, sorry for all the annoying :P can you give a quick description of the class? like what you plan on covering? they'll be set up btw, it's all good [Jun 21 18:23:48] hm [Jun 21 18:44:37] hey bgs100 [Jun 21 18:44:48] shiiiiiiiit I didn't do my homework [Jun 21 18:44:52] *sigh* [Jun 21 18:44:58] You have 20 minutes :P [Jun 21 18:46:16] yeah brb [Jun 21 18:51:32] ok [Jun 21 18:51:34] 10 minutes [Jun 21 19:07:11] bgs100, I need help with it :/ [Jun 21 19:07:43] one sec [Jun 21 19:11:43] I almost typed ./configure to compile my attempt at hw [Jun 21 19:23:41] bgs100, you lie! [Jun 21 19:23:48] No [Jun 21 19:23:59] you told me there was no way to check the length of an unknown array [Jun 21 19:24:08] uhhhhh [Jun 21 19:24:25] Not unless you have some value marking the end [Jun 21 19:24:39] pedro3005, What "way" are you talking about? [Jun 21 19:24:50] I stole this trick from google [Jun 21 19:24:53] #define arrayLen(x) (sizeof (x) / sizeof *(x)) [Jun 21 19:24:59] .... [Jun 21 19:25:09] ... [Jun 21 19:25:19] That uses sizeof on the array [Jun 21 19:25:25] That != good [Jun 21 19:25:26] I see that [Jun 21 19:25:35] why? [Jun 21 19:25:44] pedro3005, It may seem to work, but it is not guaranteed and will not work in all cases [Jun 21 19:26:07] The only reason it would work would be because gcc is a smart compiler. [Jun 21 19:26:14] Snova, Ping [Jun 21 19:26:26] Anyway [Jun 21 19:26:32] pedro3005, Okay? [Jun 21 19:26:41] I guess.. :/ [Jun 21 19:26:44] ... [Jun 21 19:26:57] pedro3005, seidos Ready for the class to begin? [Jun 21 19:27:21] I'm having a problem with the hw [Jun 21 19:27:30] Well [Jun 21 19:27:37] Let's start class and then do homework :p [Jun 21 19:27:44] I guess I can work on it during class :D [Jun 21 19:27:57] ================== C CLASS OFFICIAL BEGINNINGNESS ===================== [Jun 21 19:28:03] I think I'm close * bgs100 [Jun 21 19:28:03] frowns at seidos [Jun 21 19:28:06] Okay [Jun 21 19:28:13] pedro3005, seidos Pastebins from both of you? [Jun 21 19:28:29] of? [Jun 21 19:28:34] Homework [Jun 21 19:28:40] it's not working * pedro3005 [Jun 21 19:28:42] cries * bgs100 [Jun 21 19:28:58] throws a kleenex made of aluminum foil at pedro3005 [Jun 21 19:29:07] mine is close, it's just off by a factor of 2 [Jun 21 19:29:09] Pastebin anyway :P [Jun 21 19:29:13] I think the problem is in the sum [Jun 21 19:29:24] I'll just send you what I have [Jun 21 19:29:35] bgs100, http://paste.pocoo.org/show/228239/ [Jun 21 19:30:03] bgs100: pong [Jun 21 19:30:12] bgs100, http://paste.ubuntu.com/453127/ [Jun 21 19:30:31] Snova, Explain to pedro why his solution to getting the size of an array is bad please :P [Jun 21 19:30:54] where? [Jun 21 19:31:01] #define arrayLen(x) (sizeof (x) / sizeof *(x)) [Jun 21 19:31:04] Look up just a bit [Jun 21 19:31:41] well, it'll work, but only in cases you yourself already know [Jun 21 19:32:23] pedro3005, [Jun 21 19:32:33] Here's why your homework is broken [Jun 21 19:32:43] puts("Enter integers:"); [Jun 21 19:32:43] for (count = 0; ((input = getchar()) != EOF); count++) [Jun 21 19:32:43] array[count] = input; [Jun 21 19:33:06] You're assigning each part of "array" to the actual character [Jun 21 19:33:26] '2' == 50 [Jun 21 19:33:58] bgs100, damn it... [Jun 21 19:34:00] And newlines [Jun 21 19:34:15] array[count] = *input ? [Jun 21 19:34:27] ... [Jun 21 19:34:37] input is not a pointer. [Jun 21 19:34:40] well idk, what grabs the value? [Jun 21 19:34:43] # [Jun 21 19:34:48] % [Jun 21 19:34:49] something [Jun 21 19:34:50] pedro3005, You *have* a value [Jun 21 19:35:00] That value is a literal character [Jun 21 19:35:11] and we need to make it an int? [Jun 21 19:35:19] errr [Jun 21 19:35:28] It is an int [Jun 21 19:35:42] everything is an int, it just doesn't mean what you think it does [Jun 21 19:35:50] pedro3005, Remember when you asked me how to get a number from a character representing a number? [Jun 21 19:35:55] yeah, it's the character code [Jun 21 19:36:19] I see [Jun 21 19:36:37] what's the fix? :p [Jun 21 19:37:13] there's probably a character-to-integer function somewhere, but the quick way (not necessarily the correct way) would be input-'0' [Jun 21 19:37:31] I would recommend checking if the character represents a number with isdigit(0 from ctype.h and then if so what Snova said [Jun 21 19:37:35] isdigit()* [Jun 21 19:37:47] of course it's a number [Jun 21 19:37:56] we're asking for numbers >:( [Jun 21 19:38:03] ... [Jun 21 19:38:04] users suck [Jun 21 19:38:04] Uh [Jun 21 19:38:11] I just typed "haha" into your program; now what? [Jun 21 19:38:16] Actually [Jun 21 19:38:17] hey! I'm a user! [Jun 21 19:38:34] seidos: yes, and validating your input to make sure you aren't up to something is the bane of all programming [Jun 21 19:38:46] There's still newlines, if you're going to separate the numbers. [Jun 21 19:39:00] Actually, I would just reommend scanf'ing the numbers into your array :p [Jun 21 19:39:04] recommend* [Jun 21 19:39:09] Snova, the haha module will come out in version .02 [Jun 21 19:39:14] my program lets you do whatever you want... if what you wish is to break it, then go ahead.. it's not a bug, it's a feature [Jun 21 19:39:19] lol [Jun 21 19:39:46] pedro3005, BTW, "// Sums an array of ints;" is not actually standard C, although most compilers allow it [Jun 21 19:40:02] bgs100, why? [Jun 21 19:40:09] bgs100: // style comments [Jun 21 19:40:12] er, pedro3005 [Jun 21 19:40:16] oh [Jun 21 19:40:23] I'm not sure whether that was accepted into the C standard or not [Jun 21 19:40:31] in any case it comes from C++ [Jun 21 19:40:34] Snova, No, but I think it will be in C99 [Jun 21 19:40:41] are // style comments standard c++? [Jun 21 19:40:42] Or [Jun 21 19:40:45] Fail, not will be [Jun 21 19:40:48] is* [Jun 21 19:40:57] seidos, Mhm [Jun 21 19:40:57] ah nm, snova answered before I could even type the question [Jun 21 19:41:04] bgs100, a problem though, it never stops asking for input [Jun 21 19:41:10] pedro3005, Here: [Jun 21 19:41:11] oh [Jun 21 19:41:13] wait [Jun 21 19:41:15] I can solve it [Jun 21 19:41:15] shush [Jun 21 19:42:22] damn [Jun 21 19:42:55] It looks like I fixed the problem with my hw, bgs100, want me to send you my updated code? or am I too late? [Jun 21 19:42:59] pedro3005, :| [Jun 21 19:43:02] I'm not sure why it worked though [Jun 21 19:43:06] seidos, Sure, send it [Jun 21 19:43:12] I haven't seen yours yet :P [Jun 21 19:43:25] will this damn thing work * pedro3005 [Jun 21 19:43:29] slaps compiler [Jun 21 19:43:32] pedro3005, Do you want the link to my modification? [Jun 21 19:43:38] no [Jun 21 19:43:42] ... [Jun 21 19:44:01] bgs100, http://paste.ubuntu.com/453134/ [Jun 21 19:44:05] look [Jun 21 19:44:08] for (count = 0; ((input = getchar()) || count < size); count++) [Jun 21 19:44:08] array[count] = input-'0'; [Jun 21 19:44:11] it must be the i++, I can't move it to the bottom this time [Jun 21 19:44:36] pedro3005, [Jun 21 19:44:50] wait [Jun 21 19:44:51] fail [Jun 21 19:45:10] pedro3005, That would probably work for input like "123", but what if I wanted multi-digit numbers? :p [Jun 21 19:45:13] seidos, Good, [Jun 21 19:45:21] seidos, Your problem was, [Jun 21 19:45:52] seidos, That you were trying to access input[10] when it's length is 10 and the first elemnt is at input[0] [Jun 21 19:45:58] element* [Jun 21 19:46:15] So you were going one space too far. [Jun 21 19:46:20] oh, no, I think it was right [Jun 21 19:46:32] In fact, you still are, in the first part [Jun 21 19:46:32] hmmm [Jun 21 19:46:36] wait [Jun 21 19:46:37] bgs100, oh, I'll fix it using scanf.. But I don't have much time today.. I'll work on this again later, can we move on to the class? I must leave in ~30 minutes [Jun 21 19:46:37] s/part/loop/ [Jun 21 19:46:38] crap [Jun 21 19:46:52] pedro3005, Can I link you to the modification? :p [Jun 21 19:46:59] Meh [Jun 21 19:46:59] ok sure [Jun 21 19:47:00] it should be adding input[0]...input[10] [Jun 21 19:47:05] pedro3005, http://paste.pocoo.org/show/228243/ [Jun 21 19:47:11] when I added up the inputs manually though, I got 66, not 132 [Jun 21 19:47:22] Yeahhhh [Jun 21 19:47:29] seidos, We'll get back to that :p [Jun 21 19:47:30] yep, what I thought.. scanf [Jun 21 19:47:33] Onto class [Jun 21 19:47:47] So... [Jun 21 19:47:56] We've learned a bit about arrays... [Jun 21 19:48:26] :D [Jun 21 19:48:31] I was thinking we might go on to strings (a special kind of array with functions that apply just to it) [Jun 21 19:48:59] So, yeah [Jun 21 19:49:12] First off: A string is just an array of characters [Jun 21 19:49:29] There is a piece of the standard library dedicated to strings: string.h [Jun 21 19:49:54] Now, with string.h, there's a function called strlen() that gets the length of a string. [Jun 21 19:50:08] How could this work, since a string is an array?! [Jun 21 19:50:11] !!! [Jun 21 19:50:22] I know! [Jun 21 19:50:22] Because, strings have a special character at the end... [Jun 21 19:50:26] damn it [Jun 21 19:50:31] lol [Jun 21 19:50:35] NULL? "\0"? [Jun 21 19:50:41] \0 , which is the integer 0 in ASCII [Jun 21 19:50:50] probably everywhere else too :p [Jun 21 19:51:04] pedro3005, yeah, except '\0', not "\0" [Jun 21 19:51:17] bgs100, only char arrays end with null? [Jun 21 19:51:26] Not char arrays, strings [Jun 21 19:51:32] There is a tiny distinction [Jun 21 19:51:48] With strings, you do have the \0 at the end [Jun 21 19:51:53] char arrays = strings [Jun 21 19:52:08] With char arrays, well, you can have whatever floats your boat (no pun intended) [Jun 21 19:52:29] pedro3005, technically [Jun 21 19:52:32] yes [Jun 21 19:52:49] But you might say that not all char arrays are strings [Jun 21 19:52:56] ok [Jun 21 19:52:59] pedro3005, [Jun 21 19:53:16] ohai [Jun 21 19:53:21] When you take "Hello world" in C, you automatically have a \0 on the end [Jun 21 19:53:33] But you could have a char array that did not [Jun 21 19:53:35] So anyway [Jun 21 19:53:36] hai Snova [Jun 21 19:53:48] So yeah... [Jun 21 19:53:56] seidos, pedro3005 Any questions? [Jun 21 19:54:07] pedro3005: as arrays do not have a length, so called c-strings are initialized with a \0 at the end in the interests of string handling. only *initialized*; it's your job to maintain it [Jun 21 19:54:24] no questions here [Jun 21 19:54:32] Okay cools then [Jun 21 19:54:53] yeah cool [Jun 21 19:54:57] We've been using strings this whole time in calls to printf, fprintf, puts, and scanf [Jun 21 19:55:06] Being arrays, [Jun 21 19:55:11] all of which are implicitly assuming there is a \0 at the end [Jun 21 19:55:18] You can access the members of a string and modify them [Jun 21 19:55:48] But, as Snova said, it would probably not be good to replace the \0 without replacing it later [Jun 21 19:56:37] Also, as with arrays, [Jun 21 19:56:47] you can allocate them yourself. [Jun 21 19:57:16] (and realloc them, etc.) [Jun 21 19:58:24] If you want to declare a string (or rather char array/pointer in this case), you just take what you know with int pointers and arrays and swap int for char. [Jun 21 19:58:38] char mychararray[10]; [Jun 21 19:58:55] However, you'll want to take care if using a number, because of the extra '\0'. [Jun 21 19:59:03] You can also do things like: [Jun 21 19:59:15] char mychararray[] = "Hallo world"; [Jun 21 19:59:17] bgs100, what do you mean by "using a number"? [Jun 21 19:59:35] seidos, I mean the 10 in "char mychararray[10];" [Jun 21 19:59:40] Sorry for unclear wording [Jun 21 19:59:54] If you're declaring an array like that, is what I mean. [Jun 21 19:59:59] if you don't use a number, what else is there to use? [Jun 21 20:00:05] ... [Jun 21 20:00:10] char mychararray[] = "Hallo world"; [Jun 21 20:00:17] pedro3005, Thank you :p [Jun 21 20:00:28] that works? as like an "infinite" array? [Jun 21 20:00:30] And of course pointers [Jun 21 20:00:33] seidos, Uh no [Jun 21 20:00:53] seidos, The size of the array is just the size "Hallo world" has [Jun 21 20:01:16] but I could do char mychararray[] = "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk etc etc" [Jun 21 20:01:30] char array[∞]; [Jun 21 20:01:31] Um, sure. [Jun 21 20:01:43] pedro3005, Hahaha [Jun 21 20:01:46] Nice [Jun 21 20:02:05] pedro3005, you just solved the "matrix of reality". We're in an infinite array! [Jun 21 20:02:16] or...not * bgs100 [Jun 21 20:02:24] gives pedro3005 the Neo badge [Jun 21 20:02:32] haha [Jun 21 20:02:36] :D [Jun 21 20:02:43] pedro3005, Now do some backflips and shootings and stuff in slow-mo :P [Jun 21 20:02:54] bgs100, only in Python [Jun 21 20:02:55] I recommend practicing dodging bullets before actually trying it in real life [Jun 21 20:03:15] seidos, No, just stop them with your hand :p [Jun 21 20:03:22] better yet, teeth [Jun 21 20:03:29] well, practice first [Jun 21 20:03:34] ANYWAY [Jun 21 20:03:41] don't be like those people on LSD that think they can fly...well [Jun 21 20:03:44] yeah...anyway [Jun 21 20:03:52] anyone have a gun I can borrow for practice? [Jun 21 20:03:59] Pshaw, I can fly *begins to levitate* [Jun 21 20:04:14] import antigravity [Jun 21 20:04:15] :p [Jun 21 20:04:17] ANYWAY [Jun 21 20:04:21] C [Jun 21 20:04:21] ANYWAY [Jun 21 20:04:24] D [Jun 21 20:04:34] :p [Jun 21 20:04:37] But seriously [Jun 21 20:04:39] C-C-Combo breaker [Jun 21 20:04:43] So yeah [Jun 21 20:05:01] ... [Jun 21 20:05:08] Any questions? [Jun 21 20:05:11] none [Jun 21 20:05:17] seidos ? * bgs100 [Jun 21 20:05:32] assumes not [Jun 21 20:05:37] ONWARDS [Jun 21 20:05:42] you assume correct [Jun 21 20:06:04] Okay [Jun 21 20:06:17] Really quickly, 3 simple things that I did not mention earlier [Jun 21 20:06:19] First: [Jun 21 20:06:25] The dowhile loop [Jun 21 20:06:29] do { [Jun 21 20:06:33] stuff [Jun 21 20:06:41] } while (conditions); [Jun 21 20:06:55] It is very much like a while loop, [Jun 21 20:07:08] except the condition is checked after the body has been run [Jun 21 20:07:17] So the body will always execute at least once [Jun 21 20:07:34] Useful for when you have something like: [Jun 21 20:07:37] dostuff [Jun 21 20:07:43] while (condition) { [Jun 21 20:07:49] dotheexactsamestuff [Jun 21 20:07:51] } [Jun 21 20:08:01] Next [Jun 21 20:08:05] The switch statement [Jun 21 20:08:16] switch (variable) { [Jun 21 20:08:24] case somevalue: [Jun 21 20:08:28] dostuff [Jun 21 20:08:34] break; [Jun 21 20:08:36] } [Jun 21 20:08:41] Okay [Jun 21 20:08:54] The switch statement checks if the variable is equal to a bunch of stuff, [Jun 21 20:09:14] The break meaning it exits the switch and doesn't check for anything else [Jun 21 20:09:29] You can also have stuff like: [Jun 21 20:09:35] switch (variable) { [Jun 21 20:09:44] case value: [Jun 21 20:09:48] case othervalue: [Jun 21 20:09:53] dostuff [Jun 21 20:09:57] break; [Jun 21 20:09:59] } [Jun 21 20:10:08] do you have to put break;? [Jun 21 20:10:15] In which "dostuff" will execute if variable is value or othervalue [Jun 21 20:10:48] seidos, It makes sense to usually, since your variable probably isn't going to be two values at once. [Jun 21 20:11:04] However, you could have a case that changes the variable for a further case. [Jun 21 20:11:12] why do you put break; in the second case but in the 1st case? [Jun 21 20:11:16] seidos, So, technically not, but usually you will. [Jun 21 20:11:22] seidos, Because, [Jun 21 20:11:30] s/but/but not [Jun 21 20:11:47] We want "dostuff" to execute if the variable is either "value" or "othervalue" [Jun 21 20:12:04] We don't want to break, then. [Jun 21 20:12:14] Also [Jun 21 20:12:24] The equivalent of an "else" in switch is "default:" [Jun 21 20:12:30] switch (variable) { [Jun 21 20:12:37] case blarg: [Jun 21 20:12:43] dostuff [Jun 21 20:12:49] break; [Jun 21 20:12:55] default: [Jun 21 20:13:03] dostuff [Jun 21 20:13:10] break; [Jun 21 20:13:11] } [Jun 21 20:13:12] AND [Jun 21 20:13:23] You do not have to put the break in the default [Jun 21 20:13:29] However [Jun 21 20:13:56] It is generally good practice in case you go back and change the default to a case or add another case or something [Jun 21 20:14:05] (no pun intended) [Jun 21 20:14:15] pedro3005, seidos Questions? [Jun 21 20:14:25] just some thoughts [Jun 21 20:14:29] Yes? [Jun 21 20:14:33] it's interesting that the cases have multiple lines without {} [Jun 21 20:14:39] Yeah [Jun 21 20:14:44] and it's interesting break has a ; but not dostuff [Jun 21 20:14:52] err [Jun 21 20:15:12] seidos, That's just because I assumed you had ;'s in your dostuff :P [Jun 21 20:15:23] dostuff just represents the main body [Jun 21 20:15:29] ah okay [Jun 21 20:15:32] Sorry if that caused confusion [Jun 21 20:15:43] But anyway, about the first thought [Jun 21 20:15:59] That is a good though... it's a depart from the normal syntax * bgs100 [Jun 21 20:16:11] gives seidos the thinker badge [Jun 21 20:16:22] Okay [Jun 21 20:16:26] Maybe pedro3005 has left... [Jun 21 20:16:29] no [Jun 21 20:16:33] Oh Yay! [Jun 21 20:16:41] Okay then [Jun 21 20:16:46] pedro3005, no questions? [Jun 21 20:16:49] none [Jun 21 20:16:52] Okay [Jun 21 20:17:01] I want to see Rodin's statue with the "thinker" badge on it. that would be tight. [Jun 21 20:17:02] I guess that's why you didn't respond earlier? [Jun 21 20:17:09] seidos, Lol [Jun 21 20:17:34] Okay [Jun 21 20:17:38] Final 3rd thing [Jun 21 20:17:51] The acursed "goto" statement. * seidos [Jun 21 20:18:01] does the sign of the cross [Jun 21 20:18:09] seidos, Good idea. [Jun 21 20:18:42] The goto statement is often regarded as an evil beast, the god of spaghetti code, and in general acursed. [Jun 21 20:18:55] sounds like I'll love it [Jun 21 20:18:59] seidos, pedro3005 http://xkcd.com/292/ [Jun 21 20:19:07] It's the dinosaur one [Jun 21 20:19:10] :P [Jun 21 20:19:12] without looking [Jun 21 20:19:20] yay! [Jun 21 20:19:30] :P [Jun 21 20:19:43] bgs100, where's the badge for knowing xkcd? * bgs100 [Jun 21 20:19:50] gives that to pedro3005 [Jun 21 20:19:55] Well [Jun 21 20:20:08] I haven't read all of xkcd yet [Jun 21 20:20:12] In all honesty there's a multiple dinosaur ones :P [Jun 21 20:20:23] s/a// [Jun 21 20:20:24] Okay [Jun 21 20:20:30] So [Jun 21 20:20:41] Here's how this demon spawn works: [Jun 21 20:20:51] bgs100, I didn't get the alt-text [Jun 21 20:21:02] pedro3005, Er, uh, google it [Jun 21 20:21:08] alt-text? [Jun 21 20:21:11] This isn't xkcd class :p [Jun 21 20:21:15] oh boy [Jun 21 20:21:18] seidos, However your mouse over the comic [Jun 21 20:21:23] Hover* [Jun 21 20:21:25] Fail [Jun 21 20:21:42] ohhh [Jun 21 20:21:56] seidos, Okay? [Jun 21 20:22:00] that ones one obscure joke [Jun 21 20:22:03] was* [Jun 21 20:22:03] yeah [Jun 21 20:22:10] See the text? [Jun 21 20:22:35] ... [Jun 21 20:22:41] yeah I'm looking it up [Jun 21 20:22:44] I mean, I'm only really learning C so I can understand the jokes about C [Jun 21 20:22:50] :P jk [Jun 21 20:22:53] seidos, Hm? [Jun 21 20:22:53] haha [Jun 21 20:23:07] seidos, No, just hover your mouse over the comic [Jun 21 20:23:16] pedro3005, lol :p [Jun 21 20:23:34] bgs100, I hovered over and it said "Neal Stephenson thinks it's cute to name his labels 'dengo'. [Jun 21 20:23:39] Yes [Jun 21 20:23:43] That is alt-text [Jun 21 20:23:44] but it made no sense to me, so I'm looking it up [Jun 21 20:23:47] o [Jun 21 20:23:49] oh* [Jun 21 20:23:51] pedro3005, Well, [Jun 21 20:23:54] That's okay [Jun 21 20:23:56] bgs100, ONTO C [Jun 21 20:24:10] Because all of this C that everyone has taught to you is a lie. [Jun 21 20:24:17] GCC is an elaborate joke [Jun 21 20:24:29] I've been PMing seidos the real lessons * seidos [Jun 21 20:24:43] checks for a pm from bgs100 [Jun 21 20:25:31] maybe irc is an elaborate joke, because I never got any pms...ermmm, I mean, there they are, I just haven't had time to read them [Jun 21 20:25:35] odd, didn't see them before [Jun 21 20:25:40] ... [Jun 21 20:25:52] let's just go on then * seidos [Jun 21 20:25:54] gives his most convincing smile * bgs100 [Jun 21 20:26:04] gives seidos the Joke Ruiner badge [Jun 21 20:26:10] (jk :p) [Jun 21 20:26:29] I am "the joke ruiner!" The Joker's archnemesis [Jun 21 20:26:31] ONWARD [Jun 21 20:26:39] seidos, rofl [Jun 21 20:26:48] The was pretty good xD [Jun 21 20:26:51] That* [Jun 21 20:27:17] ONWARD, huzzah to onward! [Jun 21 20:27:22] and thank you [Jun 21 20:27:28] STUPID KEYBOARD * bgs100 [Jun 21 20:27:28] burns keyboard [Jun 21 20:27:28] OW CRAP MY HANDS [Jun 21 20:27:28] ONWARD [Jun 21 20:27:29] So [Jun 21 20:27:33] Back to goto [Jun 21 20:27:38] goto goto [Jun 21 20:27:47] So, you make a label like this: [Jun 21 20:27:50] pedro3005, har har :p [Jun 21 20:27:58] Let's say you have your code: [Jun 21 20:28:01] int main() { [Jun 21 20:28:05] blarg; [Jun 21 20:28:09] sillystuff; [Jun 21 20:28:19] thisisalabel: [Jun 21 20:28:25] morestuff; [Jun 21 20:28:28] return 0; [Jun 21 20:28:29] } [Jun 21 20:28:38] Alright? [Jun 21 20:28:44] no {}? [Jun 21 20:28:50] Nooope [Jun 21 20:28:57] how do we determine the end of a label then? [Jun 21 20:29:02] you don't [Jun 21 20:29:09] there isn't one [Jun 21 20:29:30] Ohai Snova [Jun 21 20:29:32] >.> [Jun 21 20:29:40] what's the point then? [Jun 21 20:29:50] ordinarily C code proceeds from statement to statement, making exceptions only when if/while/for denote otherwise. goto allows you to break this rule. [Jun 21 20:30:07] it simply sets the next statement to be executed to the one after your target albel [Jun 21 20:30:07] Yep [Jun 21 20:30:13] be it going backwards or forwards [Jun 21 20:30:15] I see [Jun 21 20:30:33] then if you go backwards, it'll execute all the way up to the goto again [Jun 21 20:30:34] Here's how you use goto (assuming you have a label): [Jun 21 20:30:35] right? [Jun 21 20:30:39] pedro3005: and then what? [Jun 21 20:30:44] goto somelabael; [Jun 21 20:30:52] goto somelabel;* [Jun 21 20:30:54] :p [Jun 21 20:30:54] Snova, infinite loop? [Jun 21 20:30:57] pedro3005: exactly * seidos [Jun 21 20:31:39] thinks sentience is an infinite loop [Jun 21 20:31:43] Brb, with an example. [Jun 21 20:31:44] it's the complete lack of structure therein that is why many languages today don't even have a goto statement; it's considered *very* poor form to use except in certain circumstances [Jun 21 20:31:56] Linux actually uses it a fair bit, but you'll note it's only to ensure cleanup code gets run [Jun 21 20:32:10] Linux uses it? * seidos [Jun 21 20:32:25] eyes his computer suspiciously, afraid it might crash at any moment [Jun 21 20:32:37] Lol [Jun 21 20:32:46] yes, they put some cleanup code at the bottom of a function and "goto it" as a means of simplifying the code [Jun 21 20:32:51] seidos, Quick, cross yourself some more! [Jun 21 20:32:54] :p [Jun 21 20:32:56] seidos, watch out for the dinosaur [Jun 21 20:33:00] that's about the only reason you'd want to use it, ever * seidos [Jun 21 20:33:08] says an incantation [Jun 21 20:33:24] better yet, just don't; if you think you have an opportunity to make good use of it, chances are you don't [Jun 21 20:33:36] ok [Jun 21 20:33:40] pedro3005, does the raptor get you even if you weren't the one who used the goto statement? [Jun 21 20:33:57] aw crap [Jun 21 20:34:17] I just realized I might be attacked by a velociraptor for making this example [Jun 21 20:34:29] seidos: it's the spaghetti raptor, and you aren't at fault, so probably not [Jun 21 20:34:39] it's okay if you don't compile it [Jun 21 20:34:48] http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html [Jun 21 20:34:55] lolwut, odd url [Jun 21 20:34:56] Snova, is the spaghetti raptor and the flying spaghetti monster in cahoots? [Jun 21 20:35:09] seidos: worth investigating [Jun 21 20:35:29] Indeed * bgs100 [Jun 21 20:35:35] dons detective cap * bgs100 [Jun 21 20:35:50] dons raptor defense bat [Jun 21 20:36:31] Pastebining [Jun 21 20:36:50] http://paste.pocoo.org/show/228260/ [Jun 21 20:37:00] Prepare to be murdered by raptors * bgs100 [Jun 21 20:37:17] holds raptor-defense-bat tighter [Jun 21 20:37:46] hold it * bgs100 [Jun 21 20:37:48] notices his raptor-defense-bat is just a plastic toy nightstick [Jun 21 20:37:58] why am I risking death? I mean, will I die a noble death? [Jun 21 20:37:59] I think you need to be more worried about Dijkstra... [Jun 21 20:38:03] seidos, pedro3005 SCRO while keeping lookout [Jun 21 20:38:11] Snova, Lol * pedro3005 [Jun 21 20:38:20] locks door * pedro3005 [Jun 21 20:38:23] closes window [Jun 21 20:39:00] ... [Jun 21 20:39:08] Jjst hurry up and tell em the output :p [Jun 21 20:39:10] Just* [Jun 21 20:39:30] i is 1..4 [Jun 21 20:39:36] errr [Jun 21 20:39:37] what pedro3005 said [Jun 21 20:39:41] Don't you mean 0...4? [Jun 21 20:39:46] oh yeah [Jun 21 20:39:47] 0-4 [Jun 21 20:39:54] *rolls eyes* [Jun 21 20:39:55] yeah, 0, 1, all the same [Jun 21 20:40:03] uhhh [Jun 21 20:40:09] shush [Jun 21 20:40:10] *Universe Asplodes* [Jun 21 20:40:11] on with the C [Jun 21 20:40:13] 0 = 1, that's Zen [Jun 21 20:40:32] seidos, No, I think that's just fail :p [Jun 21 20:40:38] ANYWAY [Jun 21 20:40:41] VERILY ONWARD [Jun 21 20:40:50] So basically, this code is equivalent to a for loop [Jun 21 20:40:53] yes, kind sir [Jun 21 20:40:59] for (i = 0; i < 5; i++) [Jun 21 20:41:08] printf("i is %d\n", i); [Jun 21 20:41:30] That's what this is doing [Jun 21 20:41:54] I see [Jun 21 20:41:58] Interestingly, you can also have a label after a goto. [Jun 21 20:42:01] Like so: [Jun 21 20:42:04] int main() { [Jun 21 20:42:20] if (idontwanttorunsomecode) [Jun 21 20:42:30] goto tthheeefffuuuttuuureee; [Jun 21 20:42:34] somecode; [Jun 21 20:42:38] somemorecode; [Jun 21 20:42:49] tthheeefffuuuttuuureee: [Jun 21 20:43:06] puts("WHHHOOOAAAA We're in the fffuuutttuurreee"); [Jun 21 20:43:09] return 0; [Jun 21 20:43:10] } [Jun 21 20:43:20] Okay? [Jun 21 20:43:23] makes sense [Jun 21 20:43:27] Good [Jun 21 20:43:28] seidos ? [Jun 21 20:43:50] yeah, clear as mud [Jun 21 20:43:51] as usual [Jun 21 20:43:58] ... [Jun 21 20:44:03] seidos, You have questions? [Jun 21 20:44:33] I guess it makes sense [Jun 21 20:44:39] just had to find which one was the label [Jun 21 20:44:47] Snova, why that link you sent as in a folder called copyright_violations on a directory of University of Arizona's department of sociology is beyond me [Jun 21 20:44:52] was* [Jun 21 20:45:03] seidos, there was only one label :p [Jun 21 20:45:09] And it was not indented [Jun 21 20:45:25] yeah tthheeefffuuuttuuureee: is the label [Jun 21 20:45:29] mhm [Jun 21 20:45:45] Snova, Ping [Jun 21 20:45:59] so tthheeefffuuuttuuureee; [Jun 21 20:45:59] somecode; [Jun 21 20:45:59] somemorecode; [Jun 21 20:46:04] is skipped, right? [Jun 21 20:46:09] Yes! [Jun 21 20:46:11] Good [Jun 21 20:46:15] also, at a picture of a kid flipping the camera off is present in the directory [Jun 21 20:46:18] a* [Jun 21 20:46:27] pedro3005, lolwat [Jun 21 20:46:35] bgs100, indeed [Jun 21 20:46:41] verily [Jun 21 20:46:47] I'm going to study sociology at Arizona now [Jun 21 20:46:53] xD [Jun 21 20:46:55] I wonder what kind of crazy shit they smoke [Jun 21 20:47:02] so. [Jun 21 20:47:06] moving on. [Jun 21 20:47:14] young claude. ha [Jun 21 20:47:29] Now, pedro3005, seidos, you know most of C The Language. * pedro3005 [Jun 21 20:47:44] celebrates [Jun 21 20:47:49] bgs100, then why can't I speak c? * pedro3005 [Jun 21 20:47:59] goes to program a new operating system [Jun 21 20:48:01] Hmm [Jun 21 20:48:23] maybe it's because I don't understand Dijkstra [Jun 21 20:48:35] Wait [Jun 21 20:48:37] does that mean that all that's left are projects using C to solve problems? [Jun 21 20:48:42] Were you joking, or what? * pedro3005 [Jun 21 20:49:01] grabs C book [Jun 21 20:49:05] Hey, I'm going to have to go for a few minutes soon. [Jun 21 20:49:07] there must be something here we don't know [Jun 21 20:49:15] pedro3005, Wait :p * seidos [Jun 21 20:49:25] thinks of something [Jun 21 20:49:27] bgs100, assign homework and dismiss class then [Jun 21 20:49:38] well specific functions that exist in the many include files [Jun 21 20:49:44] No, I don't have time [Jun 21 20:49:59] okay... farewell [Jun 21 20:50:07] I guess I can work on problem 2 of projecteuler [Jun 21 20:50:07] You know about data types, functions, pointers, and a lot of other stuff [Jun 21 20:50:22] And some of the standard library [Jun 21 20:50:28] We will cover more of that later [Jun 21 20:50:28] thank you bgs100 [Jun 21 20:50:30] bbs [Jun 21 20:50:35] Clas isn't over :p [Jun 21 20:50:38] Class* [Jun 21 20:50:42] :o [Jun 21 20:50:54] class is perpetual [Jun 21 20:50:57] Lol [Jun 21 20:50:58] but just because you're in class [Jun 21 20:51:01] doesn't mean you have class [Jun 21 20:51:01] Bye [Jun 21 20:51:04] bye [Jun 21 20:51:05] Be back in a few [Jun 21 20:51:10] I won't [Jun 21 20:51:14] seidos, That was zen-ish :p [Jun 21 20:51:21] bye until tomorrow [Jun 21 20:51:30] well, i'll hang out until 22 [Jun 21 20:51:47] already procrastinated the fuck out of studying for a test anyway [Jun 21 20:52:29] what test? [Jun 21 20:52:36] history / sociology [Jun 21 20:53:27] ah [Jun 21 20:53:45] whoa [Jun 21 20:53:49] this is weird [Jun 21 20:53:55] I think I'm actually disappointed class is over [Jun 21 20:54:01] mohi2911, put the logs online [Jun 21 20:54:02] I don't think that's ever happened before [Jun 21 20:54:20] seidos, hey, do you know this book? http://www.amazon.com/Sophies-World-History-Philosophy-Classics/dp/0374530718/ref=sr_1_1?ie=UTF8&s=books&qid=1277167733&sr=8-1 [Jun 21 20:54:57] never heard of it [Jun 21 20:55:15] bgs100: pong [Jun 21 20:55:50] seidos, I was reading some of it at the library today [Jun 21 20:55:52] interesting things [Jun 21 20:55:56] pedro3005, do you know this book: http://www.amazon.com/Cartoon-History-Universe-Vol-Pt-1/dp/0385265204/ref=sr_1_1?ie=UTF8&s=books&qid=1277167914&sr=8-1 [Jun 21 20:56:01] I read about Hume and remembered of that buddhism thing you said [Jun 21 20:56:04] the doctrine of no-self [Jun 21 20:56:08] Hume did have that [Jun 21 20:56:20] Hume believed in no-self? [Jun 21 20:56:40] yes [Jun 21 20:57:18] To Hume, the self is constantly bombarded by events and changes, and it does not have an immutable always-present essence, but changes itself fundamentally over time [Jun 21 20:57:40] so there is no essential immutable notion of self to Hume [Jun 21 20:58:08] a self that changes doesn't necessarily mean a self that isn't [Jun 21 20:58:38] depends on your concept of self, I guess [Jun 21 20:58:41] the Buddhist stuff is pretty dense. The monk that I talk to on facebook just linked me a bunch of stuff to read when I questioned his beliefs [Jun 21 20:59:17] seidos, it is definitely an interesting book, although it's a little too simple and detached [Jun 21 20:59:33] I don't know what the self is, it certainly appears to be intimately dependent on the brain [Jun 21 20:59:42] my question is "how did I get here?" [Jun 21 20:59:54] your mom and dad conceived you [Jun 21 20:59:57] I didn't ask to be born. My nightmare is that I'll be born again, just like I was born this time [Jun 21 21:00:16] After studying religion my hope has started to become that death is the end [Jun 21 21:00:39] nobody asks to be born, because life exists randomly, and not on a purpose... As Sartre would put it, "existence precedes essence" [Jun 21 21:00:52] that's what I say... I hope this is it [Jun 21 21:01:04] but the only way I can be certain that I won't get born again, is if I can maintain awareness. Problem is, awareness goes away at death [Jun 21 21:01:08] the infinite is sickening [Jun 21 21:01:26] some guy in #jesus was telling me "eternity is awesome" [Jun 21 21:01:29] you cannot be certain [Jun 21 21:01:35] I asked him if "hell was awesome" [Jun 21 21:01:38] he said no. [Jun 21 21:02:01] but they never actually acknowledge their mistaken views [Jun 21 21:02:19] the problem with randomness, is cause and effect [Jun 21 21:02:24] I think eternity of the self is despairing [Jun 21 21:02:29] look [Jun 21 21:02:43] an eternity free from suffering is by definition not despairing [Jun 21 21:02:49] let's first assume heaven is constant and immutable [Jun 21 21:03:35] Your presence of heaven over time would obviously diminish your happiness as time passes [Jun 21 21:03:43] to this problem, there are two solutions: [Jun 21 21:03:54] 1. there is no notion of time in heaven [Jun 21 21:04:35] this is a problem in itself, because self-consciousness only exists within time.. "the self is nothing but its act of synthesis sublime. this act must be the same to be self-conscious over time" (remember Kant?) [Jun 21 21:04:40] it follows then that: [Jun 21 21:04:46] 2. heaven must be changing [Jun 21 21:05:36] being infinite the time spent at heaven and arguably finite the number of possible states, heaven must at some point run out [Jun 21 21:05:43] following that [Jun 21 21:06:01] actually, heaven changing is consistent with scripture [Jun 21 21:06:18] Adam and Eve were perfect before they fell, implying a "heaven like perfect state" [Jun 21 21:06:38] and the mainstream xian belief of satan's fall, with 1/3 of the angels, also implies heaven is not immutable [Jun 21 21:06:39] but the movement of heaven is absurd [Jun 21 21:06:45] for heaven is perfect, and there can only be one perfect [Jun 21 21:07:03] I disagree that there is not notion of time in heaven [Jun 21 21:07:10] if there is motion, there is a notion of time [Jun 21 21:07:15] me too [Jun 21 21:07:37] but if there is motion, there is a change of state, say state A and B [Jun 21 21:07:38] it kind of makes me wonder, "If you can imagine it, does that mean that it exists"? [Jun 21 21:07:59] s/not/no [Jun 21 21:08:17] the idea of heaven is absolutely perfect [Jun 21 21:08:27] maybe the flying spaghetti monster is floating around the planet out in this very Universe [Jun 21 21:08:32] this follows that A and B are both absolutely perfect and thus alike [Jun 21 21:08:39] and if not this one...oh right, sorry I'm digressing [Jun 21 21:08:54] so the notion of change is incompatible with the notion of perfect [Jun 21 21:09:09] ah, I see your question [Jun 21 21:09:25] is it possible for two systems, A and B, both to be perfect, and different? [Jun 21 21:09:42] heaven cannot exist [Jun 21 21:10:02] perhaps there is only one perfect "system" A, that has subworlds A1, A2, A3 ... Ainfinite [Jun 21 21:10:11] I don't have the infinity symbol [Jun 21 21:10:11] if it's immutable, there is no self; if it is mutating, it is not perfect, therefore not heaven [Jun 21 21:10:35] hey, I kind of liked this argument of mine [Jun 21 21:10:46] I don't understand your logic [Jun 21 21:10:55] what do you mean by "it's"? [Jun 21 21:11:02] heaven [Jun 21 21:11:05] just take out the "its" and put in the noun [Jun 21 21:11:12] if heaven is immutable, blabla [Jun 21 21:11:28] if heaven is immutable, there is no self, if heaven is mutating, heaven is not perfect, therefore not heaven [Jun 21 21:11:39] I don't get what heaven has to do with self [Jun 21 21:11:55] if something is immutable, there cannot be a notion of time [Jun 21 21:12:05] the notion of self only exists within time [Jun 21 21:12:31] I dunno [Jun 21 21:12:37] I'm not ready to accept it [Jun 21 21:12:53] that the notion of self can only exist with time? [Jun 21 21:12:59] this reminds me of when I asked in #jesus if I got tired of being in heaven if I could just kill myself [Jun 21 21:13:04] religion is absurd though [Jun 21 21:13:13] that's what I want to show [Jun 21 21:13:16] oh, right [Jun 21 21:13:37] but this derives the old darned question of "where does the notion of self come from?" [Jun 21 21:13:47] I think "if something is immutable, there cannot be a notion of time" is an a priori statement, that may or may not be true [Jun 21 21:14:00] I depends how immutable [Jun 21 21:14:06] s/I/it [Jun 21 21:14:19] of course.. the mere passing of time is already a mutation [Jun 21 21:14:24] suppose you bring your clock to heaven [Jun 21 21:14:28] it will change [Jun 21 21:14:43] in Buddhist cosmology, even heavenly beings die [Jun 21 21:14:49] the absurd is in implying here that there is a notion of "perfect" within a watch [Jun 21 21:15:23] now play devil's advocate [Jun 21 21:15:30] I don't know [Jun 21 21:15:36] I don't think it's ironclad [Jun 21 21:15:46] it all depends on the premise that something immutable can't have time [Jun 21 21:15:50] what about something eternal? [Jun 21 21:15:54] hmmm [Jun 21 21:16:04] eternal is not necessarily defined as heaven [Jun 21 21:16:25] actually the definition of heaven in the bible doesn't say there won't be any suffering [Jun 21 21:16:29] 'eternal' is an idea with no known real correspondent [Jun 21 21:16:31] it implies it [Jun 21 21:16:36] but doesn't say it explicitly [Jun 21 21:16:43] in revelation it says there won't be any night [Jun 21 21:16:49] and no that God will wipe people's tears [Jun 21 21:16:50] hey [Jun 21 21:16:56] yeah [Jun 21 21:16:57] maybe we should make this argument in #jesus [Jun 21 21:17:06] you will be disappointed [Jun 21 21:17:12] why? [Jun 21 21:17:33] it just will get crazy with their apologetics [Jun 21 21:17:42] but I'd like to see you try, it is a noble effort [Jun 21 21:17:45] For truth! [Jun 21 21:17:51] hey, I know who I can argue this with [Jun 21 21:18:09] damn it [Jun 21 21:18:11] he's not here [Jun 21 21:18:23] I can present it in #jesus if you don't do it [Jun 21 21:18:43] heck, I'll do it [Jun 21 21:18:43] but I don't believe in it as much as you do, so may not do the presentation justice [Jun 21 21:18:54] s/may/my [Jun 21 21:19:23] pedro3005, you could also try presenting the argument in #philosophy [Jun 21 21:27:07] BAAAACKKKKK [Jun 21 21:27:54] CLASS DOTH NOT BE OVER! [Jun 21 21:27:57] wb bgs100 [Jun 21 21:27:58] VERILY! [Jun 21 21:28:15] " I think I'm actually disappointed class is over" aww :D [Jun 21 21:28:57] Hmm [Jun 21 21:29:13] pedro3005 and seidos, you two should start a philosophy class [Jun 21 21:29:23] like anyone would come [Jun 21 21:29:24] :P [Jun 21 21:30:13] we could just talk in #philosophy [Jun 21 21:30:24] same diff as a class, sorta' kinda' [Jun 21 21:30:56] I would come [Jun 21 21:31:12] :p [Jun 21 21:31:24] "bgs100 teaches C and pedro3005 and seidos discuss philosophy related to C daily at 23:00 UTC" [Jun 21 21:31:45] related to C? [Jun 21 21:31:49] not really [Jun 21 21:31:49] well, sometimes [Jun 21 21:31:55] it seems to start there [Jun 21 21:32:02] well, I guess there's no goto in heaven [Jun 21 21:32:39] lol [Jun 21 21:32:43] no goto in heaven [Jun 21 21:32:45] damn it * Snova [Jun 21 21:32:49] goes back to not being here [Jun 21 21:32:57] I need an objective perfect to disprove heaven [Jun 21 21:33:00] >:( [Jun 21 21:33:06] no raptors either [Jun 21 21:33:20] bgs100, continue, then? [Jun 21 21:33:32] bgs100, goto continue:? [Jun 21 21:33:56] how did the conversation on heaven relate to C anyway? [Jun 21 21:33:56] goto class [Jun 21 21:34:06] ha [Jun 21 21:34:09] I still don't really get classes [Jun 21 21:34:14] recursive functions are also a trip [Jun 21 21:34:19] seidos, it didn't, I abruptly changed it to Hume [Jun 21 21:34:29] recursion is easy; making it stop is somewhat harder :p [Jun 21 21:35:38] Wait [Jun 21 21:35:42] Almost done reading logs [Jun 21 21:35:49] hmmm, I wouldn't say it's easy. I'll have to review code presented in class to attempt construction a recursive f(x) [Jun 21 21:36:16] This amused me: " this reminds me of when I asked in #jesus if I got tired of being in heaven if I could just kill myself" [Jun 21 21:36:22] :p [Jun 21 21:36:34] sadly, they said yes [Jun 21 21:36:40] ... [Jun 21 21:37:06] I have the log, maybe I'll go back and reread my conversations in there for kicks [Jun 21 21:37:12] or...not [Jun 21 21:37:25] xD [Jun 21 21:37:57] Well [Jun 21 21:38:05] We've covered most of the actual language [Jun 21 21:38:18] We're going to continue with more of the standrad library [Jun 21 21:38:45] standard* [Jun 21 21:38:47] >:P [Jun 21 21:39:02] I'm with ya' [Jun 21 21:39:04] I think I've been punished for using goto via my keyboard [Jun 21 21:40:09] hmm [Jun 21 21:40:21] pedro3005, seidos What are you impressions of C and this class? [Jun 21 21:41:26] oh sure, so talkative 8 minutes ago :p [Jun 21 21:42:08] well, some thoughts off the top of my head. I really didn't think I could even get the basic ideas of C, but after the classes, and the hw, it looks like I actually was able to piece together some *very* basic programs [Jun 21 21:42:35] which has left me feeling more confident to tackle more challenging problems [Jun 21 21:42:46] :D [Jun 21 21:42:55] I still don't get the result in one of my hw assignments though, even after beating my head against over and over [Jun 21 21:42:58] Well that's good :) [Jun 21 21:43:08] s/against/against it [Jun 21 21:43:10] seidos, Okay, which assignment? [Jun 21 21:43:20] the array assignment [Jun 21 21:43:25] where we were supposed to sum [Jun 21 21:43:45] I extrapolated out the summation (at least I think), but I got a totally different answer [Jun 21 21:43:54] Okay, can you re-link to the pastebins? [Jun 21 21:44:12] if I drop the i's top value, it turns out to be the right answer when I do it manually on a calculator [Jun 21 21:44:14] yeah [Jun 21 21:44:43] Also [Jun 21 21:44:45] http://paste.ubuntu.com/453127/ [Jun 21 21:44:54] okay [Jun 21 21:45:04] seidos, Here is the problem [Jun 21 21:45:12] int input[10]; [Jun 21 21:45:18] I don't feel safe with structs [Jun 21 21:45:22] You declare input to have a length of 10 [Jun 21 21:45:25] I don't think I can use them quite well [Jun 21 21:45:28] pedro3005, Okay, one sec [Jun 21 21:45:31] looping from 0 to 10 inclusive will iterate ELEVEN times [Jun 21 21:45:38] Yeah [Jun 21 21:45:40] your loop conditions should be < 10 [Jun 21 21:45:47] seidos, And thus you try to access input[10] [Jun 21 21:45:58] remember in an array of length 10, the indexes are 0-9 inclusive [Jun 21 21:46:04] When your elemtns only go from input[0] to input[9] [Jun 21 21:46:13] elements* [Jun 21 21:46:31] but shouldn't both loops have the same number of iterations? [Jun 21 21:46:36] seidos, Yes [Jun 21 21:46:47] yes. and they should be running 10 times each, but they're running 11 iterations [Jun 21 21:47:00] So replace "i<11" with "i<10" in both of them [Jun 21 21:47:02] which is, at the least, one problem [Jun 21 21:47:21] ah [Jun 21 21:47:34] Besides that it looks fine [Jun 21 21:47:37] wait, I still don't get [Jun 21 21:47:38] it [Jun 21 21:47:51] What don't you get? [Jun 21 21:47:55] but you're saying if I change both loops to i<10 then it will work? [Jun 21 21:48:06] maybe, maybe not, but it's a bug nonetheless [Jun 21 21:48:09] I take in 11 inputs [Jun 21 21:48:15] then it adds 11 times [Jun 21 21:48:21] but your array only has 10 elements [Jun 21 21:48:22] it should come out to the right value [Jun 21 21:48:22] Yes, because that way you won't be trying to access input[10] [Jun 21 21:48:29] ohhhhh [Jun 21 21:48:30] crap [Jun 21 21:48:33] :P [Jun 21 21:48:43] so it's 0 to 9 [Jun 21 21:48:44] dang it [Jun 21 21:48:51] Yes [Jun 21 21:48:57] seidos, Get it now? [Jun 21 21:49:19] I won't believe until it's compiled and shows the right answer :P [Jun 21 21:49:30] seidos: also, something worth mentioning is there is a shorthand for "sum = sum + input[i];", the += operator. "sum += input[i]" is equivalent, and there are many other compound operators like this (+=, -=, *=, /=, etc.) [Jun 21 21:49:57] I don't think it will change the fact that it's wrong, unless you're trashing the stack somehow... [Jun 21 21:50:09] but there's no obvious problems; it's a simple sum [Jun 21 21:50:20] Compiled the fix and it works [Jun 21 21:50:25] I never would've found that problem [Jun 21 21:50:40] I was looking in the loops for the problem when it was in my array declaration :( [Jun 21 21:50:45] Er [Jun 21 21:50:52] well, I guess it could have been the loops if I reduced both of them to 10 [Jun 21 21:50:56] I would say it was a problem with your loops :p [Jun 21 21:51:02] but that didn't make sense without knowing why [Jun 21 21:51:09] bgs100: only if 10 is necessarily better than 11 somehow :p [Jun 21 21:51:11] Well, now ya know why [Jun 21 21:51:21] Snova, Pshaw, of course it is [Jun 21 21:51:25] Well [Jun 21 21:51:29] not in base 11! [Jun 21 21:51:33] Except for 11 being a number-palindrome [Jun 21 21:51:38] and it's prime [Jun 21 21:51:41] Mm [Jun 21 21:51:45] hmmmmm [Jun 21 21:51:45] Good point [Jun 21 21:51:51] number systems based on prime numbers [Jun 21 21:52:01] And there's a multiple of it in "1337" [Jun 21 21:52:17] Yeah, 11 is pretty awesome [Jun 21 21:52:35] Oh, and we're up to the 11th Doctor :p [Jun 21 21:52:38] the += operator is a trip [Jun 21 21:52:56] lol [Jun 21 21:52:59] Snova, Your arguments have changed my mind! [Jun 21 21:53:00] it's easy [Jun 21 21:53:03] 11 pwns 10 [Jun 21 21:53:05] bgs100: :| [Jun 21 21:53:06] x = x + y [Jun 21 21:53:09] x += y [Jun 21 21:53:12] Snova, What? :p [Jun 21 21:53:25] there's a variable in that += [Jun 21 21:53:29] that's weird [Jun 21 21:53:34] bgs100: nothing. there should be a number system based on primes though, instead of the arbitrary "ten" [Jun 21 21:53:35] :D [Jun 21 21:53:51] Good night. [Jun 21 21:53:55] a number system based on primes? [Jun 21 21:53:56] g'night [Jun 21 21:53:57] Night pedro3005 [Jun 21 21:53:58] night pedro3005 [Jun 21 21:54:06] ah [Jun 21 21:54:08] 2 is prime [Jun 21 21:54:09] Snova, Ten isn't arbitary! It's ten in base ten! [Jun 21 21:54:14] :P [Jun 21 21:54:38] so base 2 is a number system based on a prime number [Jun 21 21:54:44] Whatever base 10 may happen to be [Jun 21 21:55:03] not quite what I meant... I don't really know what I mean [Jun 21 21:55:08] Lol [Jun 21 21:55:13] they wouldn't be primes anymore [Jun 21 21:55:19] 0_0 [Jun 21 21:55:33] wwhhoooaaaa [Jun 21 21:56:36] Actually [Jun 21 21:56:47] Why wouldn't they be? [Jun 21 21:56:54] [Jun 21 21:57:35] because as soon as you count to four in your prime-based number system, you meet a number that isn't prime [Jun 21 21:57:39] [Jun 21 21:59:16] does that mean the primes are different based on the base? * seidos [Jun 21 21:59:45] shakes head [Jun 21 22:00:11] :/ [Jun 21 22:00:22] I was thinking of counting in primes [Jun 21 22:00:23] Oh [Jun 21 22:00:27] I misunderstood [Jun 21 22:00:31] instead of 1,2,3,4,5 we'd go 2,3,5,7,11 [Jun 21 22:00:43] Ah... [Jun 21 22:00:45] except those numbers are only primes in base ten [Jun 21 22:00:50] Yeah [Jun 21 22:00:52] 7 would be 4, and not prime [Jun 21 22:00:52] Also [Jun 21 22:00:56] FRREEE UNNIICOODEEE [Jun 21 22:00:59] І wіη, ⅿυаҺаҺаҺа. Моаr соⅼօrÑ•! [Jun 21 22:01:01] also, I have no idea what the heck it would be useful for [Jun 21 22:01:13] so it would be different, but not really [Jun 21 22:01:26] I mean 7 is still 7, even if it's represented as a different number in a different base [Jun 21 22:02:13] yes, but the fourth number in any number system is divisible by the second number [Jun 21 22:02:17] 3 * 3 = 7 [Jun 21 22:03:03] & * & = ((( [Jun 21 22:03:05] :p [Jun 21 22:03:18] Hmm * bgs100 [Jun 21 22:03:39] imagines a number system where O + M + G = 0_0 * seidos [Jun 21 22:03:46] tries to count in binary [Jun 21 22:03:56] I have to convert it to count [Jun 21 22:03:58] 1, 10, 11, 100, 101, 110, 111 [Jun 21 22:04:03] not hard [Jun 21 22:04:20] Just carrying some numbers every other time :P [Jun 21 22:04:24] so 0100 is divisible by 0010 [Jun 21 22:04:29] crap, I almost said visible [Jun 21 22:04:30] yes, lots and lots of carrying [Jun 21 22:04:32] hmmm that works [Jun 21 22:04:36] and I can't do anything in it except count :p [Jun 21 22:04:53] well, I can see that, since if only one bit is set it's a power of two [Jun 21 22:05:36] 111 + 10 = 1001 [Jun 21 22:05:40] I think? :p [Jun 21 22:05:52] I don't know how to add in binary without converting [Jun 21 22:05:59] hrm [Jun 21 22:06:04] to base 10...well, or using a calculator [Jun 21 22:06:07] 1101? [Jun 21 22:06:18] no, bgs was right [Jun 21 22:06:21] Yeah [Jun 21 22:06:27] I could probably do it on paper [Jun 21 22:06:31] yes [Jun 21 22:06:33] Like: [Jun 21 22:06:37] 111 [Jun 21 22:06:39] ah, carrying [Jun 21 22:06:40] 010 [Jun 21 22:06:42] + [Jun 21 22:06:45] ___ [Jun 21 22:06:56] 1001 [Jun 21 22:07:10] right [Jun 21 22:07:15] makes sense [Jun 21 22:07:21] now how do you multiply? [Jun 21 22:07:22] mhm [Jun 21 22:07:26] ... [Jun 21 22:07:32] 111 [Jun 21 22:07:33] * [Jun 21 22:07:35] 010 [Jun 21 22:07:37] ____ [Jun 21 22:07:58] 1110? [Jun 21 22:08:12] I dunno, I just keep anding it basically [Jun 21 22:08:20] Let's convert and see if I'm right [Jun 21 22:08:31] 7 * 2 [Jun 21 22:08:34] yeah [Jun 21 22:08:40] 14 [Jun 21 22:08:41] Yes [Jun 21 22:08:44] I am right :D [Jun 21 22:08:44] I used the binary calculator in gnome * bgs100 [Jun 21 22:08:58] does a little dance [Jun 21 22:09:10] how'd you do it? [Jun 21 22:09:14] what is 1 * 0 if not 0? [Jun 21 22:09:14] Well [Jun 21 22:09:18] seidos, [Jun 21 22:09:24] 0 * 111 = 0 [Jun 21 22:09:41] ah [Jun 21 22:09:42] 1 (in the next place) * 111 = 111 (one place up) [Jun 21 22:09:45] which is 1110 [Jun 21 22:09:49] ah distributing it [Jun 21 22:09:52] forgot to do that [Jun 21 22:09:53] and add [Jun 21 22:09:56] It was literally 10 * 1111 [Jun 21 22:10:01] er [Jun 21 22:10:03] 111* [Jun 21 22:10:08] now do 100/10 [Jun 21 22:10:18] never mind [Jun 21 22:10:21] 10 [Jun 21 22:10:32] amiright? :p [Jun 21 22:10:43] annoyingly enough you're right in both base 2 and base 10 :p [Jun 21 22:10:51] :D * bgs100 [Jun 21 22:11:07] declares himself binary expert! :p [Jun 21 22:11:26] still don't get the division [Jun 21 22:11:31] Well [Jun 21 22:11:35] can't do it on paper, get the * though [Jun 21 22:11:40] Do it like in decimal [Jun 21 22:11:56] ___ [Jun 21 22:12:04] ha! [Jun 21 22:12:05] 10|100 [Jun 21 22:12:11] 6 + 6 = C [Jun 21 22:12:20] 10 goes into 1 zero times [Jun 21 22:12:28] 10 goes into 10 1 tim [Jun 21 22:12:32] time* [Jun 21 22:12:38] 10 goes into the next 0 0 times [Jun 21 22:12:40] thus 010 [Jun 21 22:13:01] Snova, :p [Jun 21 22:13:22] 10000000/10 = 100000 [Jun 21 22:13:46] I'm doing it on paper to help me visualize it [Jun 21 22:13:51] I remember for you fathers day I got some hexadecimal numbers and got my Dad to add them. The answer was DAD [Jun 21 22:13:57] s/you/one/ [Jun 21 22:14:14] heh [Jun 21 22:14:40] geek seems to run in the family [Jun 21 22:14:42] This year I made him decode some various ciphertext :p [Jun 21 22:14:49] hahaha [Jun 21 22:15:17] I just sent my Dad an email [Jun 21 22:15:28] Although I basically had to spell out for him how to use the Vignere cipher even though I had told him before :p [Jun 21 22:15:56] The key was the answer to some other ciphertext :p [Jun 21 22:16:02] haha [Jun 21 22:17:02] Snova, But yeah. My Dad is very much into math. [Jun 21 22:17:59] my Dad isnt really into math [Jun 21 22:18:10] the only person really into math are my brother and I [Jun 21 22:18:16] Ah [Jun 21 22:18:34] my brother specialized in AutoCAD, and makes a living at it [Jun 21 22:18:59] I have no specialty [Jun 21 22:20:50] Sometimes my dad drags me over to him and attempts to teach me some math, and occasionally I try to teach him some Python/C/Common Lisp/Shell/Various other stuff :p [Jun 21 22:21:41] my Dad has tried to teach me anthropology, I think [Jun 21 22:22:02] trying to remember the stuff he's talked about [Jun 21 22:23:09] he did a study on left vs right handedness [Jun 21 22:23:16] not sure what the hypothesis was [Jun 21 22:24:03] I should call him and ask someday }}}