![]() |
[QUOTE=science_man_88;239480]Yeah same with comment(s) like they say [COLOR="Red"]no passwords in plain text[/COLOR] you may get lost trying to read uncommented code, But some random other person could have just as hard of a time until they figure it out.[/QUOTE]
"No passwords in plain text" has nothing to do with comments in source code. |
My encode of rle isn't perfect for example:
RLE(hello world) = 1H1e2l1o1w1o1r1l1d RLE("Hello world") = 1H1e2l1o[COLOR="Red"]10[/COLOR]1w1o1r1l1d so they don't code out the same and so my decode will likely have to compensate unless my encode is redone. |
[CODE](12:54) gp > checkstring(string) = eval(vector(Vec(Str(string))))
%90 = (string)->eval(vector(Vec(Str(string)))) (12:56) gp > checkstring(string) *** vector: gtos expected an integer, got '["s", "t", "r", "i", "n", "g"]'.[/CODE] catch the error and you complete [url]http://rosettacode.org/wiki/Determine_if_a_string_is_numeric[/url] no ? actually maybe not you'd have to check if it's not a number list, Oh well my mistake again... |
[QUOTE=science_man_88;239482]My encode of rle isn't perfect for example:
RLE(hello world) = 1H1e2l1o1w1o1r1l1d RLE("Hello world") = 1H1e2l1o[COLOR="Red"]10[/COLOR]1w1o1r1l1d so they don't code out the same and so my decode will likely have to compensate unless my encode is redone.[/QUOTE] Solution: Don't ever, ever, ever pass strings without quoting them. If you do, you're going to end up with nonsense like this where your first example omits the space. Passing strings without quotes causes serious issues and does not work in all cases. Don't do it. (When you do this, what's actually happening is you're sending monomials which are evaluated to their own names (!), but if a values becomes associated you'll see that instead of what you wanted.) Your improper use of eval() caused the space to be read as 0 rather than as a space. |
[QUOTE=science_man_88;239491][CODE](12:54) gp > checkstring(string) = eval(vector(Vec(Str(string))))
%90 = (string)->eval(vector(Vec(Str(string)))) (12:56) gp > checkstring(string) *** vector: gtos expected an integer, got '["s", "t", "r", "i", "n", "g"]'.[/CODE][/QUOTE] To check the type of a variable, look at type(variable). If it's a string the type will be "t_STR". type(0) is t_INT type(1/2) is t_FRAC type(x^3 + 1) is t_POL type(x) is t_POL type(hello) is t_POL type("hello") is t_STR and so forth. |
[CODE](13:18) gp > for(x=1,10,print1(x);if(x!=10,print1(",")))
1,2,3,4,5,6,7,8,9,10 (13:18) gp > for(x=1,10,print1(x);if(x==10,break());print1(",")) 1,2,3,4,5,6,7,8,9,10 (13:19) gp > for(x=1,9,print1(x);print1(","));print(10) 1,2,3,4,5,6,7,8,9,10 (13:20) gp > for(x=1,9,print1(x","));print(10) 1,2,3,4,5,6,7,8,9,10[/CODE] not sure which implementation is best for [url]http://rosettacode.org/wiki/Loops/N_plus_one_half[/url] lol |
[url]http://rosettacode.org/wiki/Pattern_matching[/url]
right up my alley just not sure what i want to do for it. |
[QUOTE=science_man_88;239498][CODE](13:18) gp > for(x=1,10,print1(x);if(x!=10,print1(",")))
1,2,3,4,5,6,7,8,9,10 (13:18) gp > for(x=1,10,print1(x);if(x==10,break());print1(",")) 1,2,3,4,5,6,7,8,9,10 (13:19) gp > for(x=1,9,print1(x);print1(","));print(10) 1,2,3,4,5,6,7,8,9,10 (13:20) gp > for(x=1,9,print1(x","));print(10) 1,2,3,4,5,6,7,8,9,10[/CODE] not sure which implementation is best for [url]http://rosettacode.org/wiki/Loops/N_plus_one_half[/url] lol[/QUOTE] I've given some thought to that myself. I think to go with the spirit of the problem a while(1, ...) loop might be best. |
[QUOTE=CRGreathouse;239501]I've given some thought to that myself. I think to go with the spirit of the problem a while(1, ...) loop might be best.[/QUOTE]
unless a while has a otherwise do this part it wouldn't all be in the loop and: [QUOTE]Quite often one needs [B]loops[/B] which, in the [B]last iteration[/B], execute only [B]part of the loop[/B] body. The goal of this task is to demonstrate the best way to do this. Write a loop which writes the comma-separated list[/QUOTE] suggest it should be part of the loop which knocks out all but the first 2 in my group, as well as possibly a while, or do until. never mind dah if statements lol. |
I can't quite follow you, but
[code]n=0; while(1, print1(n++); if(n>9, break); print1(", ") );[/code] does the trick. |
[QUOTE=CRGreathouse;239497]To check the type of a variable, look at type(variable). If it's a string the type will be "t_STR".
type(0) is t_INT type(1/2) is t_FRAC type(x^3 + 1) is t_POL type(x) is t_POL type(hello) is t_POL type("hello") is t_STR and so forth.[/QUOTE] so in other words if(string==type(0) ||string==type(1/2), print("this string is numerical")) would work ? Though I haven't covered floating point types. |
| All times are UTC. The time now is 23:10. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.