|
Avenging Dentist posted:Generally, I think it's best to pick one style and use it for both variables and methods. It just makes things more consistent. i use underscore_deliminated_method_names and CamelCaseVariableNames generally. in some languages it's extremely nice to be able to differentiate between the two at a glance.
|
# ? Feb 27, 2008 03:08 |
|
|
# ? May 15, 2024 03:00 |
|
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. Match whatever your language/environment uses. If neither of those give any guidance, just be consistent.
|
# ? Feb 27, 2008 03:29 |
|
Appa Time! Yeah, I build a list of primes first to test against. Here's my code if you'd like; it's pretty simple. I'm not very complex.code:
|
# ? Feb 27, 2008 05:37 |
|
narbsy posted:Appa Time! Yeah, I build a list of primes first to test against. Here's my code if you'd like; it's pretty simple. I'm not very complex. Jesus, I modeled mine more after yours and it gave me the correct answer almost instantly. My old way ran for 15 minutes and still didn't find it. Thanks a lot man.
|
# ? Feb 27, 2008 07:29 |
|
TI BASIC question. I wrote my first program for my 83 that solves the quadratic formula. The problem is that my program gives decimal approximations instead of exact value when dealing with square roots. How do I program it to show exact values?
|
# ? Feb 27, 2008 19:43 |
|
No problem Appa Time!! My pleasure. Triangulum: There is a site devoted to TI programming, here. There's a ton of stuff, and if all else fails you can download an example program that does what you want to learn from.
|
# ? Feb 27, 2008 22:04 |
|
Triangulum posted:TI BASIC question. I wrote my first program for my 83 that solves the quadratic formula. The problem is that my program gives decimal approximations instead of exact value when dealing with square roots. How do I program it to show exact values? I don't think the 83 will show square roots inline like the 89 or 92 does. Just to make sure I understand, you're plugging in values to a solver, it's spitting out "1.732..". and you want it to say "sqrt(3)" instead? Your best bet is to also print out the square of all the numbers given to see if they're integers, otherwise it's going to be a guessing game.
|
# ? Feb 27, 2008 22:12 |
|
Triangulum posted:TI BASIC question. I wrote my first program for my 83 that solves the quadratic formula. The problem is that my program gives decimal approximations instead of exact value when dealing with square roots. How do I program it to show exact values? code:
|
# ? Feb 27, 2008 22:23 |
|
The TIcalc site has a quadratic solver that expresses the answer as a radical but I don't have a link cable. Maybe I can convince the one person in my class with this version of the quad EQ program to give me a look at the code so I can figure out how the gently caress it was done. It's not a huge deal or incredibly important but it's driving me nuts and I would like to learn how to do it.
|
# ? Feb 27, 2008 22:54 |
|
Triangulum posted:The TIcalc site has a quadratic solver that expresses the answer as a radical but I don't have a link cable. Maybe I can convince the one person in my class with this version of the quad EQ program to give me a look at the code so I can figure out how the gently caress it was done. It's not a huge deal or incredibly important but it's driving me nuts and I would like to learn how to do it. If the program posted is actually TI-Basic you should be able to open the file in just a text editor to view the source without a cable. Granted you'd have to reimplement the program yourself if you want it on your calculator, but it would tell you how it is done.
|
# ? Feb 27, 2008 23:12 |
|
I had assumed that as well until I opened the files in Notepad and got a huge string of gibberish. I could also be a moron, who knows!
|
# ? Feb 27, 2008 23:29 |
|
6174 posted:If the program posted is actually TI-Basic you should be able to open the file in just a text editor to view the source without a cable. Granted you'd have to reimplement the program yourself if you want it on your calculator, but it would tell you how it is done. No, the Ti-83 is too cool to do real tokenization, so it's essentially a binary format.
|
# ? Feb 27, 2008 23:42 |
|
Triangulum posted:I had assumed that as well until I opened the files in Notepad and got a huge string of gibberish. I could also be a moron, who knows! Interesting. I remember just opening the files in a text editor when I used to play with programs on my TI-86 and then 89. Maybe it was the linking software allows you to view the programs? This was many years ago though, so my memory is a little fuzzy on some of the details. 6174 fucked around with this message at 23:56 on Feb 27, 2008 |
# ? Feb 27, 2008 23:54 |
|
6174 posted:Interesting. I remember just opening the files in a text editor when I used to play with programs on my TI-86 and then 89. Maybe it was the linking software allows you to view the programs?
|
# ? Feb 28, 2008 00:35 |
|
6174 posted:Interesting. I remember just opening the files in a text editor when I used to play with programs on my TI-86 and then 89. Maybe it was the linking software allows you to view the programs? You should be able to open them in the TI Connect software, or whatever it's called now. That's assuming they're in BASIC, if they're written in assembly you're kind of hosed, but I'm assuming that no one went to the trouble to hand-write QUADFORM in assembly And if you get a program from TI's official site, it's pretty much guaranteed to be BASIC.
|
# ? Feb 28, 2008 00:51 |
|
I have a client at work that has two mirror sites translated into German and Spanish. All three sites are hosted on the same server. The translated sites are relatively new and since they launched, they've started having submissions to their contact forms that include non-english characters. When the form outputs the submission emails anything not english, say, letters with accents, umlauts or tilde (for spanish characters) they are replaced in the email body with strange approximations and not the correct characters. And if it matters, the sites are all in ASP classic. I've never had to deal with anything like this in the past and I'm not sure how to fix it. I've been letting this one slide for a while and people are starting to ask questions. Any ideas?
|
# ? Feb 28, 2008 01:38 |
|
You can also get an emulator for the TI-83 and open it up in there. I think there were a few listed on the website.
|
# ? Feb 28, 2008 03:33 |
|
Kaiju posted:I have a client at work that has two mirror sites translated into German and Spanish. All three sites are hosted on the same server. The translated sites are relatively new and since they launched, they've started having submissions to their contact forms that include non-english characters. When the form outputs the submission emails anything not english, say, letters with accents, umlauts or tilde (for spanish characters) they are replaced in the email body with strange approximations and not the correct characters. "Text encoding" is the keyword you'll be looking for, as that's the problem. The users are sending characters to the web server in a character set that your email can't contain, probably because your email is sending as ASCII. You'll have to send the emails using the correct text encoding, whatever that might be. I think it'll be whatever encoding the form's page is being sent in, but I'm not sure. The web development thread folks might know right off the bat.
|
# ? Feb 28, 2008 05:23 |
|
csammis posted:"Text encoding" is the keyword you'll be looking for, as that's the problem. The users are sending characters to the web server in a character set that your email can't contain, probably because your email is sending as ASCII. You'll have to send the emails using the correct text encoding, whatever that might be. I think it'll be whatever encoding the form's page is being sent in, but I'm not sure. The web development thread folks might know right off the bat. Thanks, man. That's a start.
|
# ? Feb 28, 2008 13:14 |
|
I'm writing a bash script that involves a long series of pipes. I also want to make it readable. Is there a simple way to put these on multiple lines and making bash treat it as one single line of input? code:
|
# ? Feb 28, 2008 17:28 |
|
axolotl farmer posted:I'm writing a bash script that involves a long series of pipes. I also want to make it readable. What you are looking for is called a line continuation character. In the case of bash it is \
|
# ? Feb 28, 2008 17:45 |
|
6174 posted:What you are looking for is called a line continuation character. In the case of bash it is \ Oh yes it is. My error was caused by something else.
|
# ? Feb 28, 2008 18:11 |
|
I understand that we're supposed to keep language specific questions in their related threads, but I don't see any current threads on shell scripting or sed. If I'm wrong, feel free to ridicule me. With that out of the way, my question is about using regular expressions with sed. I'm searching a line of numbers and symbols and only want a certain group of numbers. My input string will look like this: code:
I've tried the following (and many variations) with no luck. This regex makes the most sense to me in this context: code:
|
# ? Feb 28, 2008 19:06 |
|
Must be sed's interpretation of regex, I wasn't able to convince it to do what you want (not even anything as simple as '[0-9]+' was matching, so either I was being retarded in my sed usage or that's the aspect it doesn't support...?) but Python's RE library works fine, I think it's largely PCRE compatible:quote:re.findall(r'[0-9]+\(([0-9]{1,3})%',"16(100%)") Upon further investigation, it looks like you need the -E flag for sed to use extended regex instead of simple: quote:jeff@jeff.local:~ $ echo "16(100%)" | sed -Ee "s/[0-9]+\(([0-9]+)%\)/\1/" EDIT: I used + instead of {1,3} there but same difference in this case Also, I used + instead of * for the earlier part, which is probably better unless your input sometimes lacks the leading number entirely; I also removed the all-encompassing parentheses which I am pretty sure were extraneous bitprophet fucked around with this message at 20:03 on Feb 28, 2008 |
# ? Feb 28, 2008 19:59 |
|
bitprophet posted:Must be sed's interpretation of regex, I wasn't able to convince it to do what you want (not even anything as simple as '[0-9]+' was matching, so either I was being retarded in my sed usage or that's the aspect it doesn't support...?) but Python's RE library works fine, I think it's largely PCRE compatible: It doesn't look like my version of sed (4.0.7) supports -E, which seems odd. Maybe it's a GNU thing? Either way, your post (and a cup of tea) showed me exactly what I was missing, and it's totally embarrassing. I was forgetting to give sed a search command! I'm so ashamed of myself right now. With a little fiddling I was able to get your version to work and my problem is solved. Thank you very much!
|
# ? Feb 28, 2008 20:21 |
|
Here's my very ugly take on it! echo "16(100%)" |sed 's/[()%]/ /g'|awk '{print $2}'
|
# ? Feb 28, 2008 20:28 |
|
axolotl farmer posted:Here's my very ugly take on it! That's a cool method as well (took me a second to spot the space), and it's not nearly as ugly as the entire command I'm using to get my string. Thanks to everyone for the replies.
|
# ? Feb 28, 2008 20:37 |
|
Wrong thread.
dest fucked around with this message at 00:43 on Feb 29, 2008 |
# ? Feb 29, 2008 00:34 |
|
furtheraway posted:I only want the numerals between the first parenthesis and the percent sign. That group can contain from one to three numerals. How do I extract it? code:
re_format(7) posted:Obsolete (``basic'') regular expressions differ in several respects. `|'
|
# ? Feb 29, 2008 01:16 |
|
Don't think we have a bash scripting thread yet, and at any rate I'm not any good with it... What does -a mean in a [ ] expression? Googling for it is kind of a pain, and the bash resources I found were no help. edit: Never mind, found it; it's a logical and. It just looked strange because of the context I saw it in. Incoherence fucked around with this message at 03:10 on Feb 29, 2008 |
# ? Feb 29, 2008 02:57 |
|
furtheraway posted:I understand that we're supposed to keep language specific questions in their related threads, but I don't see any current threads on shell scripting or sed. If I'm wrong, feel free to ridicule me. It might be simpler (and possibly faster) to just 'cut' twice instead of sed: code:
|
# ? Feb 29, 2008 03:38 |
|
is it possible to style individual items in a ListBox in C#? If so, how? EDIT: After much rearranging of my google query terms I found the answer: http://www.csharphelp.com/archives2/archive312.html gotta replace the DrawItem Event Handler and set the drawing stuff myself Lamb-Blaster 4000 fucked around with this message at 08:26 on Feb 29, 2008 |
# ? Feb 29, 2008 05:51 |
|
Dog Named Duke posted:A C# question For the future: .Net (C#, VB.NET) Questions Megathread
|
# ? Feb 29, 2008 14:59 |
|
Plastic Jesus posted:It might be simpler (and possibly faster) to just 'cut' twice instead of sed: That's an excellent point. Using a regex in my situation is overkill. I think I'll just use this method.
|
# ? Feb 29, 2008 16:24 |
|
code:
|
# ? Mar 2, 2008 01:44 |
|
Appa Time! posted:
Reverse of the empty list is the empty list. Reverse of any list is taking the first element off, reversing the rest, and appending the first element back onto the end. When you try to reverse an empty list: (reverse ()), mylist is null so the return is () When you try to reverse one: (reverse (1)) is: append (reverse (rest (1))) (list (first (1))) rest (1) is () and first (1) is 1 which is append (reverse ()) (1) which is append () (1) which is (1). reverse (2 1) is: append ( reverse (rest (2 1))) (list (first (2 1))) rest (2 1) is (1) and first (2 1) is 2. append (reverse (1)) (2) reverse (1) is (1) from above, and (list 2) is (2) append (1) (2) which is (1 2).
|
# ? Mar 2, 2008 01:57 |
|
Oh I see now, now I just have to translate it into java. Thanks. Edit: drat, I can't get this to work now in Java. I don't think there is a "rest" function for lists in java, so I did this: code:
sd6 fucked around with this message at 03:18 on Mar 2, 2008 |
# ? Mar 2, 2008 02:50 |
|
Appa Time! posted:
An empty list isn't null in Java, it's just empty. size() == 0.
|
# ? Mar 2, 2008 03:32 |
|
csammis posted:An empty list isn't null in Java, it's just empty. size() == 0. Right you are, fixed it and it works just fine now. Thanks guys!
|
# ? Mar 2, 2008 05:03 |
|
|
# ? May 15, 2024 03:00 |
|
So I was (not now, earlier) and programming and thinking about the finally statement. Is there any god drat reason for the finally statement? The only situation I see using finally in is if I didn't want to put a catch statement after a try which is a horrible practice anyways. And even if I did want to do that, couldn't I just use catch { } instead? Sorry if I'm retarded and there actually is a good use for finally and I just never figured it out. Edit: C#.
|
# ? Mar 2, 2008 05:37 |