|
Goodness the old one had been going a long time A Paradigm Shift: This thread is now for generic questions about coding, and language-neutral short programming questions (or languages for which there isn't already a megathread). If you've got a question about a specific language, and there's a megathread for it, better to post it there where the language-specific THE MEGATHREADS Apple App Development: iOS (iPhones and iPads), Mac OS X, Xcode, Cocoa C/C++ Programming Questions Not Worth Their Own Thread Cavern Reading List - Recommend and Request reading material Flash Questions Megathread Java questions which don't deserve their own thread, yet. Game Development Megathread Want to Learn Haskell? .Net (C#, VB.NET [VB 2003, 2005, and 2008]) Questions Megathread The Perl Short Questions Megathread: executable line noise <?PHP questions that don\\'t need their own thread ?> Python information and short questions megathread. Ruby on Rails Love-In Scientific/Math(s) Computing: numerical/statistical analysis tools and CASs - R, Matlab, etc. SELECT * FROM Questions WHERE Type = 'Stupid' Version Control Questions Megathread (SVN / git / whatever else) Web Design/Development Small Questions - Rev Holy Grail Small Excel Question Not Worth Its Own Thread If I missed one, or a new one appears, PM me to get it listed here HOT GOON ACTION Now you too can chat with real life nerds, 24/7 because we don't have lives or sleep! Join the CoCs at #cobol on irc.synirc.net, we are happy to answer your questions while mocking you and randomly replacing words with "butt." Don't like talking to or looking directly at nerds but want to gain their power, just like Highlander?! Check out http://sn.printf.net/, the CoC goon blog aggregator. Read more about it here, right here csammis fucked around with this message at 15:01 on Aug 16, 2016 |
# ? Feb 22, 2008 16:13 |
|
|
# ? May 19, 2024 15:19 |
|
Let's get this party started:Jose Cuervo posted:poopiehead, do you know of a good way to search for a particular key in a dictionary without actually knowing the key, but only a unique characteristic? I know that the key I am looking for is the one the has the longest string length (and there is a key with a longest string length in my dictionary). Right now I am useing the following loop to get the key: Note, this is a good example of a question that belongs in this thread because it's language-agnostic Iterating through the keys to find what you're looking for is the only way to do it at any given time, unless you want to use a "compiler solution" and throw another list at it that consists the keys sorted by the property you want, which you would add to whenever you insert a new key into the dictionary. I can't really imagine that there's a good reason to do this. But along those lines: Wherever you're adding an entry to the dictionary, how about you just add a check to see if the key that's being added satisfies the property you want, and save it?
|
# ? Feb 22, 2008 16:23 |
|
csammis posted:But along those lines: Wherever you're adding an entry to the dictionary, how about you just add a check to see if the key that's being added satisfies the property you want, and save it? I think I am going to go with this method. On a related note, (although this is VB specific), if I wanted an array or a dictionary to be accessible by any function in any part of my code (even if it is in a different class), what would I need to put in my main to do that? I would prefer the array/dictionary to be read only, but this is not crucial.
|
# ? Feb 22, 2008 16:41 |
|
I'll state my question using Java terminology, but I'm curious as to whether there's a general name for this kind of data structure. Recently I came upon the need for a data structure that is a bit of a cross between a Map and a Set. I ended up calling it BinaryRelation<L, R>. Its most important methods are: code:
I've already written the Java code to implement this, so I'm not asking how it can be done, but I'm curious - is there a general name for this kind of data structure? Has it been implemented in any popular programming languages or libraries? I wasn't able to find anything like this after a bit of Googling and I was surprised because it seems like such a useful way of describing a relation between two sets of objects. I know for certain I'm going to use it in every web application I make from here on out.
|
# ? Feb 23, 2008 08:14 |
|
That kind of relationship is referred to as "many-to-many" but I'm not sure what a data structure that implements it would be called. I've only ever seen this sort of thing in persistence libraries modelling the same thing in a database, but they don't tend to use a specialised structure. With one-to-one multiplicity this would be a "bidirectional map", but that's not what you've done here. Essentially you're just holding a list of graph edges with a specialised interface to it, as far as I can tell? Edit: That last one basically answered itself. I think the data structure you've made is probably pretty much a graph data structure, and you could implement your interface with an adjacency list or an adjacency matrix pretty well. The interface just looked kinda strange . Since you differentiate left and right I guess you're essentially representing a directed graph as well. zootm fucked around with this message at 10:32 on Feb 23, 2008 |
# ? Feb 23, 2008 10:23 |
|
What are some good resources/books on programming theory?
|
# ? Feb 24, 2008 08:38 |
|
fret logic posted:What are some good resources/books on programming theory? What aspect are you interested in? Algorithms? Data structures? Programming Languages (either specific language or in general)? Program design? Numerical Analysis? Operating Systems? Something else? Also a bit about your background may help so you don't get recommended something that is either too simple or too hard.
|
# ? Feb 24, 2008 08:55 |
|
6174 posted:What aspect are you interested in? Algorithms? Data structures? Programming Languages (either specific language or in general)? Program design? Numerical Analysis? Operating Systems? Something else? I'm just a CS freshman with little to no background in anything beyond basic Java/C syntax. Was just wanting to get some basic theory in my head while I'm learning these languages.
|
# ? Feb 24, 2008 09:24 |
|
fret logic posted:I'm just a CS freshman with little to no background in anything beyond basic Java/C syntax. Was just wanting to get some basic theory in my head while I'm learning these languages. In that case I'd recommend two books. First, The Practice of Programming by Kernighan and Pike. It will help get some good practices in your head and is a good choice for someone still pretty new to programming. Second is Code Complete by McConnell. It is a handbook of practical advice.
|
# ? Feb 24, 2008 09:29 |
|
fret logic posted:I'm just a CS freshman with little to no background in anything beyond basic Java/C syntax. Was just wanting to get some basic theory in my head while I'm learning these languages. If you want some "deep" theory, check out Knuth's "Art of Computer Programming" series (be warned, they are very, very math-heavy).
|
# ? Feb 24, 2008 09:41 |
|
6174 posted:In that case I'd recommend two books. First, The Practice of Programming by Kernighan and Pike. It will help get some good practices in your head and is a good choice for someone still pretty new to programming. Second is Code Complete by McConnell. It is a handbook of practical advice. I'll check those out, thanks! Should I wait until I have a language down pretty well to read Code Complete? Avenging Dentist posted:If you want some "deep" theory, check out Knuth's "Art of Computer Programming" series (be warned, they are very, very math-heavy).
|
# ? Feb 24, 2008 09:50 |
|
Avenging Dentist posted:If you want some "deep" theory, check out Knuth's "Art of Computer Programming" series (be warned, they are very, very math-heavy). This book is the Computer science version of Walter Pistons "Counterpoint" and "Harmony" , THE canonical bibles on music theory, but also complete brainfucks for people first reading them. If you DO struggle through Knuth's works, do so reverently, Knuth may be hard , but you get that when dealing with the sacred texts of God himself.
|
# ? Feb 24, 2008 10:13 |
|
Avenging Dentist posted:If you want some "deep" theory, check out Knuth's "Art of Computer Programming" series (be warned, they are very, very math-heavy).
|
# ? Feb 24, 2008 10:20 |
|
fret logic posted:I'll check those out, thanks! Should I wait until I have a language down pretty well to read Code Complete? If you've taken a course or two of programming, you'll be adequately prepared for a large chunk of Code Complete. Of course if you have less experience it may take longer to wade through, but with some motivation you could do it. Also a note about Knuth's books. They are very good, but I'm not sure Avenging Dentist's warning is quite strong enough. To be able to digest any of it you'll want to have at least some experience with discrete math (proof techniques, some set theory, etc) and algorithms/data structures. For many topics TAOCP is the best reference you'll find. However it is very dense, and not really friendly to someone just starting out. I'd strongly recommend you look at a copy from the library before you even think of anything like buying them. If you look at them and find them to be too much, look for the book Concrete Mathematics by Graham et al. It is designed to contain the math one needs to tackle TAOCP and would be a good intermediary step (and I'd still recommend some discrete math before tackling Concrete Mathematics).
|
# ? Feb 24, 2008 10:23 |
|
Professor Science posted:Oh that series that people have on their bookshelf so they can be like, "Oh, yes, I've read the Art of Computer Programming, yessssss, I am smoking a pipe now?" Has this man read TAOCP?
|
# ? Feb 24, 2008 16:37 |
|
Since you've already done some C, I'll recommend The C Programming Language. A lot of it will just be review, but it makes some things you might have a foggy understanding more precise and it's actually incredibly concise and accessible. Depending on where you're going with CS, Mythical Man Month, Extreme Programming Explained, and Pragmatic Programmer are pretty great reads more focused on programming as a profession/art than CS theory. Probably want to wait a year or two for these or at least re-read in a few years though, not because they're hard(they're not), but because more experience puts them into context.
|
# ? Feb 24, 2008 16:42 |
|
fret logic posted:I'm just a CS freshman with little to no background in anything beyond basic Java/C syntax. Was just wanting to get some basic theory in my head while I'm learning these languages. http://www.cs.rochester.edu/~scott/pragmatics/ http://www.amazon.com/Programming-Language-Pragmatics-Michael-Scott/dp/1558604421 This book is extremely awesome.
|
# ? Feb 24, 2008 19:46 |
|
What is a good book to learn database programming? I am starting a co-op where they do SQL programming, and we're coding with Java. I have no experience with SQL or database programming.
|
# ? Feb 24, 2008 21:07 |
|
Rheingold posted:http://www.cs.rochester.edu/~scott/pragmatics/ Agreed, and the author is a great professor to boot
|
# ? Feb 24, 2008 22:46 |
|
fret logic posted:What are some good resources/books on programming theory?
|
# ? Feb 25, 2008 00:51 |
|
Scaevolus posted:Structure and Interpretation of Computer Programs Seconding this. Especially for a beginner who has only learnt an imperative language yet.
|
# ? Feb 25, 2008 01:39 |
|
csammis posted:Has this man read TAOCP?
|
# ? Feb 25, 2008 02:16 |
|
Oh, I guess if we're going to talk about algorithms books we should talk about CLRS. Probably the Dragon Book for compilers, Dinosaur Book for high-level OS concepts, Russell and Norvig for AI, Computer Systems: A Programmer's Perspective for an intro to systems programming...
|
# ? Feb 25, 2008 04:07 |
|
Need some help with one of the project Euler puzzles. It's the one where you have to find the largest prime factor of 317584931803. I made a method I called isPrime(int x), where you test x % (2 to x^1/2 inclusive) and if any of those is 0, it returns false, otherwise it returns true. Well that helper method worked for the smaller example case (largest prime factor of 13195), but when I tried it for 317584931803, it ran for several minutes and still didn't find the answer, so I killed it. I'm trying the fermat primality test instead for the smaller case, but it doesn't seem very accurate. I'm also worried that I might have problems using that algorithm for the larger case, since there is no nextLong method for the java Random class. Am I on the right track with using the fermat test? Is there another algorithm I should be using?
|
# ? Feb 25, 2008 07:10 |
|
Professor Science posted:Oh, I guess if we're going to talk about algorithms books we should talk about CLRS. Probably the Dragon Book for compilers, Dinosaur Book for high-level OS concepts, Russell and Norvig for AI, Computer Systems: A Programmer's Perspective for an intro to systems programming... I didn't like the dinosaur book, Tenenbaum was much better. Also, I would suggest Stevens - Advanced Programming in the Unix Environment.
|
# ? Feb 25, 2008 07:48 |
|
more falafel please posted:I didn't like the dinosaur book, Tenenbaum was much better.
|
# ? Feb 25, 2008 08:05 |
|
Professor Science posted:isn't tenenbaum basically a source walkthrough of minix, though? that seems kind of silly.
|
# ? Feb 25, 2008 10:47 |
|
Professor Science posted:isn't tenenbaum basically a source walkthrough of minix, though? that seems kind of silly. It's more the other way around -- minix is the example used in a book about how operating systems are written.
|
# ? Feb 26, 2008 02:51 |
|
What's top's interface called? I have a static program that polls the state of a few machines, I'd like to just wrap it up and have it constantly update to the same screen, but I don't even know what to search for to rip off how top prints out to the terminal.Appa Time! posted:Need some help with one of the project Euler puzzles. It's the one where you have to find the largest prime factor of 317584931803. I made a method I called isPrime(int x), where you test x % (2 to x^1/2 inclusive) and if any of those is 0, it returns false, otherwise it returns true. Well that helper method worked for the smaller example case (largest prime factor of 13195), but when I tried it for 317584931803, it ran for several minutes and still didn't find the answer, so I killed it. I'm trying the fermat primality test instead for the smaller case, but it doesn't seem very accurate. I'm also worried that I might have problems using that algorithm for the larger case, since there is no nextLong method for the java Random class. Am I on the right track with using the fermat test? Is there another algorithm I should be using?
|
# ? Feb 26, 2008 20:32 |
|
JawnV6 posted:What's top's interface called? I have a static program that polls the state of a few machines, I'd like to just wrap it up and have it constantly update to the same screen, but I don't even know what to search for to rip off how top prints out to the terminal. I think top just uses ncurses, which is a generic console interface library, and basically what any console program with a UI at all uses.
|
# ? Feb 26, 2008 20:35 |
|
JawnV6 posted:317584931803 is larger than can be stored in an int. Yeah I should have mentioned that I used longs for the larger case. That's not the problem, my algorithm works it's just that it's worst case time is horrible for larger stuff, so I was looking for a better alternative.
|
# ? Feb 26, 2008 21:55 |
|
more falafel please posted:I think top just uses ncurses, which is a generic console interface library, and basically what any console program with a UI at all uses. Appa Time! posted:Yeah I should have mentioned that I used longs for the larger case. That's not the problem, my algorithm works it's just that it's worst case time is horrible for larger stuff, so I was looking for a better alternative.
|
# ? Feb 26, 2008 22:47 |
|
Appa Time!: did you take out the even numbers in your test? That can help a large amount. I.e. test 2, then skip by 2s from 3 on. Makes it go quicker-er. I did it in javascript and it finished pretty quickly, if I recall correctly. Yeah, just tested now. It took about 30 seconds for 600851475143, the new number for problem 3. narbsy fucked around with this message at 23:04 on Feb 26, 2008 |
# ? Feb 26, 2008 22:52 |
|
Really stupid question about Visual Studio 2008: I don't normally write Visual C stuff, but I found a tool that I absolutely must have, and it was only available as source code. After a lot of rigamarole, I've managed to get a compiled .exe, but the file won't run on any other system! The error is always the same: The system cannot execute the specified program. I've tried installing the Visual C Runtime Libraries (for both 2005 & 2008) on my test machine, but it doesn't seem to make any difference. I know I'm probably being stupid, but I can't seem to figure out how to make this thing work. P.S. -- I only have the following includes, which I don't think are anything out of the ordinary: code:
Edit: Er, this may be more appropriate for the C/C++ thread... if so, just tell me.
|
# ? Feb 26, 2008 23:07 |
Is it more common to write variables as someVariable or some_variable? I can't decide which to use. I like using someMethod() instead of some_method(), so I'm thinking it would make more sense to use some_variable.
|
|
# ? Feb 27, 2008 00:50 |
|
fletcher posted:Is it more common to write variables as someVariable or some_variable? I can't decide which to use. I like using someMethod() instead of some_method(), so I'm thinking it would make more sense to use some_variable. The popularity of that kind of style issue depends on the language in which you are working.
|
# ? Feb 27, 2008 00:55 |
|
Mister Biff posted:Edit: Er, this may be more appropriate for the C/C++ thread... if so, just tell me. Yes, either that or the .NET thread (as you're working with Visual Studio), but try the C/C++ thread first.
|
# ? Feb 27, 2008 00:56 |
|
fletcher posted:Is it more common to write variables as someVariable or some_variable? I can't decide which to use. I like using someMethod() instead of some_method(), so I'm thinking it would make more sense to use some_variable. Generally, I think it's best to pick one style and use it for both variables and methods. It just makes things more consistent.
|
# ? Feb 27, 2008 01:17 |
|
narbsy posted:
I tried your suggestion and used the new number for the problem, it still did the same thing, ran for about four minutes and I gave up. I'm skipping evens in the primality test and the main method that checks if it's a factor of 600851475143. What kind of prime test are you using? JawnV6 posted:
Could you elaborate on this? I kind of get what you mean, but how do I go about building that list?
|
# ? Feb 27, 2008 02:29 |
|
|
# ? May 19, 2024 15:19 |
|
Appa Time! posted:I tried your suggestion and used the new number for the problem, it still did the same thing, ran for about four minutes and I gave up. I'm skipping evens in the primality test and the main method that checks if it's a factor of 600851475143. What kind of prime test are you using? If you're more specific about exactly what you are doing someone can probably point out what you are doing that is slow. Also the thing JawnV6 mentioned is known as the Sieve of Eratosthenes.
|
# ? Feb 27, 2008 02:58 |