|
StumblyWumbly posted:Hey, I'm a hard/firmware guy who only writes in C, Verilog and VHDL. Python. Some will say Perl, but Perl is terrible. Others will say Ruby, which is a better choice, but I think Python will fit your background better.
|
# ? Apr 2, 2008 20:22 |
|
|
# ? May 15, 2024 02:51 |
|
JoeNotCharles posted:Python. I don't it's fair to dismiss a language as terrible without any explanation. In fact you didn't even mention why ruby or python are any better than Perl at text processing which has always been Perl's forte.
|
# ? Apr 2, 2008 21:06 |
|
MEAT TREAT posted:I don't it's fair to dismiss a language as terrible without any explanation. In fact you didn't even mention why ruby or python are any better than Perl at text processing which has always been Perl's forte. It may not be "fair", but it's accurate. Perl is a terrible language, and I would strongly advise everyone to avoid as hard as possible. Ruby and Python aren't better than Perl at text processing - Ruby is just as good (because it stole all its text handling from Perl, so it's pretty much the same in that respect), and has the advantage of not being terrible in all other respects. Python is slightly more cumbersome, but not enough to be a huge problem, and will be easier to pick up for somebody who only knows C because it doesn't have a lot of new control-flow constructs to learn.
|
# ? Apr 2, 2008 21:16 |
|
Yeah, go either with Python, Perl or Ruby. Check out some code examples to see which syntax you like the best. Their text parsing capabilities I'd say are on par, although Ruby and Perl have regexes build right into the syntax, but Python is good with regexes too. Also I think Python would have a minimum learning curve. Also Ruby's main thing is a lot of stuff you probably won't really need for text parsing, like closures and metaprogramming. And Perl is known for not being able to read your own code after 5 minutes of writing it.
|
# ? Apr 2, 2008 22:39 |
|
Uhh, whatever. If you want the job done in a blindingly fast manner with respect to time invested/development speed, go Perl, absolutely. If these go beyond "one time use" then either 1) learn how to program good, defensive Perl 2) choose a different language. Perl is tits at processing text. Let no one tell you otherwise. How the code looks is completely different from how it got it done. And it gets it done quickly and sexily. Well, in that retarded, gruesome, camel kinda way.
|
# ? Apr 2, 2008 23:20 |
|
Chiming in with the whole "You can write bad unreadable code in any language" point. I would recommend the shell if you were on a unix machine, as it is perfectly capable of small text processing tasks. Do what bonus says and go and look at some examples and pick one. Really the advantages and disavantages between the choices of ruby, perl and python are trivial at best for the tasks you want.
|
# ? Apr 2, 2008 23:25 |
|
Triple Tech posted:Uhh, whatever. If you want the job done in a blindingly fast manner with respect to time invested/development speed, go Perl, absolutely. Ruby is better than Perl for this. quote:If these go beyond "one time use" then either 1) learn how to program good, defensive Perl 2) choose a different language. Everything goes beyond a one time use. Learning to program "good, defensive Perl" is a huge undertaking compared to learning how to program well in any other language. The language structure is just set up to throw everything together and lash it up with whatever's handy. Sure, some people have the discipline to write intricate, well-designed code in Perl, but if you're just starting out so you have nothing invested in Perl, why would you go to the effort?
|
# ? Apr 2, 2008 23:59 |
|
6174 posted:TAOCP is The Art of Computer Programming by Knuth. StumblyWumbly posted:Hey, I'm a hard/firmware guy who only writes in C, Verilog and VHDL.
|
# ? Apr 3, 2008 00:32 |
|
JawnV6 posted:I'll look into those two, does CLRS have any clear discussion on hashes? I've got that on my shelf at home, not quite sure why I didn't check it in the first place. CLRS has some discussion according to the table of contents.
|
# ? Apr 3, 2008 00:56 |
|
edit: ughh wrong thread
Acer Pilot fucked around with this message at 10:41 on Apr 3, 2008 |
# ? Apr 3, 2008 03:32 |
|
I'd just like to point out that Perl has changed in the last decade, so please stop getting your Perl code from Matt's Script Archive. It'd also be nice if people would discuss programming without getting into language debates.. StumblyWumbly: I'd recommend any of Perl, Python, or Ruby. I know Perl can run fine on Windows, but I don't know about the other two. Look up ActiveState Perl or Strawberry Perl.
|
# ? Apr 3, 2008 04:37 |
|
I forgot to mention that one reason I specifically recommended Python was that I know it works extremely well on Windows (I actually prefer the Windows installer from python.org to ActiveState Python, which has add-ons). I also was in too much of a hurry earlier to say the reason I recommend it to someone who knows C - a lot of the built-in libraries it comes with are organized like common POSIX libraries, so it should be quite familiar to someone who mainly knows C.
|
# ? Apr 3, 2008 06:29 |
|
JoeNotCharles posted:It may not be "fair", but it's accurate. Perl is a terrible language, and I would strongly advise everyone to avoid as hard as possible. Why don't you try making recommendations without sparking a language debate? Even though your rose-colored (or ruby-colored ha ha) evaluation of Python and Ruby's text processing capabilities as compared to Perl's are amusing.
|
# ? Apr 3, 2008 06:44 |
|
floWenoL posted:Why don't you try making recommendations without sparking a language debate? Even though your rose-colored (or ruby-colored ha ha) evaluation of Python and Ruby's text processing capabilities as compared to Perl's are amusing. Because the guy specifically asked for text-processing languages, so I knew somebody very early on would say, "Perl is the no-brainer for this," which it is not.
|
# ? Apr 3, 2008 15:38 |
|
JoeNotCharles posted:Because the guy specifically asked for text-processing languages, so I knew somebody very early on would say, "Perl is the no-brainer for this," which it is not. Why don't you spell out for us what text-processing tasks Perl is so terribly unsuited for that Python and Ruby spank it at?
|
# ? Apr 3, 2008 15:52 |
|
Why don't you two take this outside and settle this like real programmers ?
|
# ? Apr 3, 2008 15:57 |
|
I mean seriously it's not like we have Perl or Python or Ruby threads so people can decide for themselves what they should use
|
# ? Apr 3, 2008 16:15 |
|
tef posted:Why don't you two take this outside and settle this like real programmers ?
|
# ? Apr 3, 2008 23:23 |
|
Mustach posted:Whoah, outside? What kind of language-warring programmer goes out there? Obligatory jargon file link: The Big Room
|
# ? Apr 4, 2008 02:03 |
Matlab question: I've written up a program to perform multiple linear regression, and instead of handling numbers in normal, decimal format, it spits them out like 1/3450*9402285^(1/2). My first thought was that I'd jut forgotten to undo a format rat after the last lab class, but no matter how many times I enter format, format short g, or anything else, it stays in that form, which fprintf statements don't seem to like. How the heck do I bully it into using plain ol' decimal form? I've had a couple other weird issues (errors when it tries to print, errors when putting a legend on a plot) so I'm thinking I might just need to reinstall, but I figured it would be best to check first.
|
|
# ? Apr 4, 2008 03:00 |
|
Is there a name for the algorithm to convert a sorted list to a balanced binary search tree (something more efficient than iterating over the list and inserting items into an AVL tree)? I think I can do it in O(n), but Knuth probably already created a better algorithm 30 years ago or something. I have a crappy illustration of what I mean (the left hand side of the diagram, I've already figured out what f(x) is)
|
# ? Apr 4, 2008 03:15 |
|
Scaevolus posted:Is there a name for the algorithm to convert a sorted list to a balanced binary search tree (something more efficient than iterating over the list and inserting items into an AVL tree)? I think I can do it in O(n), but Knuth probably already created a better algorithm 30 years ago or something. Uhm... a sorted array is a balanced binary tree. The top node is the index closest to the middle, which you can get in constant time as long as you know the highest index, the left subtree is all indices before it, and the right subtree is all indices after it.
|
# ? Apr 4, 2008 03:32 |
|
ShoulderDaemon posted:Uhm... a sorted array is a balanced binary tree. The top node is the index closest to the middle, which you can get in constant time as long as you know the highest index, the left subtree is all indices before it, and the right subtree is all indices after it.
|
# ? Apr 4, 2008 03:37 |
|
Incoherence posted:Sounds like he wants to start with a sorted array and make a balanced binary tree so that he can add more crap to it (with O(lg n) insertion instead of O(n)). Well then O(n) is a trivially provable lower bound, because he needs one access per node in order to create the complete tree (although he could construct a lazy tree). To build a new tree you'd just walk the old tree in preorder and build the new tree with a balanced assumption. code:
|
# ? Apr 4, 2008 03:45 |
|
Sorry, let me try to explain better. I don't need to modify this tree after I've created it. By balanced binary search tree, I mean a balanced left-heavy tree, that is, the number of nodes to the right is <= the number of nodes to the left. Basically, I want to flatten this binary tree in an array, where I know the position of the children nodes based only on the index of the parent node. In my example, I'm transforming {1,2,3,4,5,6} to {4,2,6,1,3,5}. The question is if this process has a name I can use to refer to it easily?
|
# ? Apr 4, 2008 04:17 |
|
Scaevolus posted:Sorry, let me try to explain better. No name that I'm aware of. But again, if you already have a sorted array, then you already have such a tree available. In this case, you'd have to tweak the code I provided so that it enforces the left-heavy nature of the tree: code:
|
# ? Apr 4, 2008 05:05 |
|
ShoulderDaemon posted:If you don't want to construct the pointers, then obviously you can just iterate the index discovery expression used here. Never mind, I was just wondering if there was a name for it.
|
# ? Apr 4, 2008 05:15 |
|
I have a form on a webpage that has like 50 checkboxes. I'm using a javascript function to validate the form. I'm trying to formulate an IF statement that returns true if there are more than one of those boxes checked. I'm thinking the XOR operator would be best in this situation, but apparently javascript doesn't have a xor operator... This is what I'm kind of wanting to do:code:
I found this page, which talks about this issue, but it quickly degrades into moon language with exclamation marks and carrots everywhere. Whats the cleanest way to do this?
|
# ? Apr 5, 2008 08:20 |
|
nbv4 posted:I have a form on a webpage that has like 50 checkboxes. I'm using a javascript function to validate the form. I'm trying to formulate an IF statement that returns true if there are more than one of those boxes checked. I'm thinking the XOR operator would be best in this situation, OK, no. XOR will tell you the parity of your checkboxes, but it won't tell you if more than one was checked. If the variables checkbox1, checkbox2, etc. are all either 1 or 0, then just add them together and verify that the result is exactly 1.
|
# ? Apr 5, 2008 08:29 |
|
nbv4 posted:and no, using radio buttons instead is not a proper solution. But back to your original question: logical-XORing a bunch of poo poo together just tells you whether an odd number of them are true. Easiest way to find out if more than one is true is just to assign a value (0, 1) to each and add them up.
|
# ? Apr 5, 2008 08:48 |
|
I am currently running GHCi on Windows, the version is 6.8.2 and I seem to be missing some functions that I find around in various Haskell references. For example when I try using nub, sort, or groupBy it says that they're not in scope. It looks like about 25% of functions are missing. Am I using an older version or do I have to import some modules for those functions to work or what?
|
# ? Apr 5, 2008 11:00 |
|
nbv4 posted:I have a form on a webpage that has like 50 checkboxes. I'm using a javascript function to validate the form. I'm trying to formulate an IF statement that returns true if there are more than one of those boxes checked. Put an on change in each checkbox - when it is set add one to a total, and when it is unset substract one. The form is valid if the total is greater than one?
|
# ? Apr 5, 2008 11:02 |
|
Bonus posted:I am currently running GHCi on Windows, the version is 6.8.2 and I seem to be missing some functions that I find around in various Haskell references. For example when I try using nub, sort, or groupBy it says that they're not in scope. It looks like about 25% of functions are missing. Am I using an older version or do I have to import some modules for those functions to work or what? The three functions you mentioned are all in Data.List. To import modules in GHCi you use :m +<name>.
|
# ? Apr 5, 2008 15:06 |
|
tef posted:Put an on change in each checkbox - when it is set add one to a total, and when it is unset substract one. The form is valid if the total is greater than one?
|
# ? Apr 5, 2008 17:50 |
|
hey wiz posted:If he used an on change event, why not deselect all other check boxes before selecting the current one? Along the same lines.... Why a checkbox and not a radio box? no need to write code to enforce rules that the browser will enforce for free
|
# ? Apr 5, 2008 19:44 |
|
To anyone who knows Javascript - would you respond and let me know that you actually know what you are talking about. I'm looking for some answers to help me with my web page. -C
|
# ? Apr 5, 2008 21:26 |
|
Why don't you just post your question here, or in this thread, I'm sure there's plenty of people who actually know javascript. -N
|
# ? Apr 5, 2008 21:51 |
|
hey wiz posted:If he used an on change event, why not deselect all other check boxes before selecting the current one? Because that's really confusing for the user.
|
# ? Apr 6, 2008 04:10 |
|
Plastic Jesus posted:Because that's really confusing for the user.
|
# ? Apr 6, 2008 04:19 |
|
|
# ? May 15, 2024 02:51 |
|
nbv4 posted:and no, using radio buttons instead is not a proper solution. Bullshit.
|
# ? Apr 6, 2008 07:23 |