I have no particular reason of learning Perl, except for its \'Magnificient\' implementation of regular expressions lol.
Apart from that, I think it\'s a powerful language worth knowing.
After knowing some Perl, maybe I\'ll start with TCL and later with Python. I know some C already and that helps a lot.
Merry Christmas also and a Happy New Year.
PS: For the $trans issue, trying to do it yourself is the first step to start re-learning regexps. Good luck !
PS: In fact, no regexps are \'simple\' before you understand what you\'re writing. For example in this pattern /(.)/, there\'s
everything or \'maybe not\'. Now, try to find out why I said \'maybe not\'. ;)
Fixed. (I hope lol) :)
alias parser {
return $regsubex($1-,/((sin|asin|acos|atan|cos|tan|log|sqrt)\\\\050(-?\\\\d+(?:\\\\.\\\\d+)?(?:[\\\\*\\\\/\\\\+-]\\\\d+(?:\\\\.\\\\d+)?)*)\\\\051)/g,$($\\\\2($calc(\\\\3)) $+ .deg,2))
}
NB:
When you put this fix in your source, remember to include the \\ as they are!
In your last update, I see the parser function as follows:
alias parser return $regsubex($1-,/((sin|asin|acos|atan|cos|tan|log|sqrt)50(-?d+(?:.d+)?)51)/g,$($2($calc(3)) $+ .deg,2))
(All the \\ are absent :s.)
That apart, here\'s from where I\'ve started regexps.
http://www.scriptsdb.org/tutar.php?id=1 (french site)
Then, I\'ve used these also.
http://www.cs.utah.edu/dept/old/texinfo/regex/regex.html
http://www.pcre.org/pcre.txt
http://en.wikipedia.org/wiki/Regular_expression
http://www.regular-expressions.info/
http://www.expreg.com/ (french site)
and some more sites found on google. :)
The $regsubex identifier is just a possibility that can be used once you know regexp.
I only learnt regexps and then made applications using mIRC mainly.
Now I\'m learning Perl. But that\'s another chapter lol.
Cordialement :)
In the trans function there are these 2 lines which could be optimized a bit imho.
%eq = $regsubex(%eq,/(\\\\d)x/g,\\\\t*x)
%eq = $regsubex(%eq,/(\\\\d[a-z])/g,$remove(\\\\t,$regsubex(\\\\t,\\\\d+,\\\\t)) $+ * $+ $regsubex(\\\\t,\\\\d+,\\\\t))
Basically, both of them does the same thing, except for the first which considers only the \'x\' character after a digit.
They could be replaced by this single line.
%eq = $regsubex(a,%eq,/(\\\\d)([a-z])/g,\\\\1*\\\\2)
;o)
There you are.
1> supports negative numbers inside the trigonometric functions, like sin(-30) for example.
2> calculates directly the contents of the argument of the trigonometric function (still not using $stript).
alias parser {
return $regsubex($1-,/((sin|asin|acos|atan|cos|tan|log|sqrt)\\\\050(-?\\\\d+(?:\\\\.\\\\d+)?)\\\\051)/gx,$($\\\\2($calc(\\\\3)) $+ .deg,2))
}
Cordialement :o)
My coding was not in any way done to compete with yours. It\'s just that I\'ve some kinda \'Perlish\' philosophy which is \"There is more than one way to do it\". As for the speed concerns, ok, i\'m beated. But that\'s not important really (for me personnally ;)) when it\'s only that amount of milliseconds on 10000 passes. And if the issues I\'ve pointed out were wanted, then ok. :o)
Cordialement
I think that another bug will raise up once you fix this one. :s
Because, the $regsubexes are not named, it conflicts with previous $regmls and recalling for a previous match if another $regsubex was called. Therefore, just by naming differently each $regsubex, it shall be fixed. If that fixes future bugs, then great, otherwise, I\'ll help again. :)
(Or any other person who knows regexps !)
Cordialement
There you go.
Usage: $_split(,[C])
alias _split {
var %label = $color(info) * $!_split(<string>,[C]):
if $isid {
if $1 {
var %sep = $chr($iif($2,$v1,32))
return $left($regsubex($1,/(.)/g,\\\\1%sep),-1)
}
else { echo %label insufficient parameters }
}
else { echo %label use only as an identifier! }
}
I didn\'t included N because it\'s only \"Another way to do it\". :)
It\'s a good idea but imho, there are some things that it does which should not.
1) removal of double chars (most probably because of the $addtok\'s natural behaviour)
2) even though the chars in double are not close to each other, one of them, the second one, is removed also (once more, $addtok\'s fault).
3) //echo $split.text(mirc,44,5) echoes
m,i,r
c
which imo in not what it should do because the text in input does not even contain 5 chars. When spliting at N, it should not count the Cs also.
Furthermore, the error message will never be displayed, for the simple reason that you set %k inside a condition that is out of context when an error, in this case, is to be detected.
What I would like it to do.
1) with $split.text(text,44) it should echo \"t,e,x,t\" and not \"t,e,x\"
2) with $split.text(text,44,5) it should echo \"t,e,x,t\" also and not \"t,e,x\"
\"t\"
for the same reason I gave above.
Alright for the \'review\'.
[ $mid is your friend :p ]
[ I\'ll try to scratch something like this with regexps (my passion lol) ]
Cordialement
It seems that backslashes are truncated when posting. I can\'t seen any of them in my last post.
Here\'s the code with plain \'backslash\' in it which are to be replaced for sure.
alias rtrig.x {
return $regsubex($1-,/(sin|cos|tan)(x+)/g,\'backslash\'1 $+ $regsubex(s,\'backslash\'2,/(x)/g,$+($chr(40),x,$chr(41))))
}
Here\'s a solution.
alias rtrig.x {
return $regsubex($1-,/(sin|cos|tan)(x+)/g,\\1 $+ $regsubex(s,\\2,/(x)/g,$+($chr(40),x,$chr(41))))
}
Usage (as an identifier): $rtrig.x(string)
I\'ve included only sin, cos and tan functions. You can add what you want in the alternating group \" (sin|cos|tan) \".
Cordialement :)
Personnally, I would appreciate very much if you could post a fully-commented version so as to understand the internals of your solver. As is actually, I can only judge the coding (which by the way, is very good) and not the algorithm. And that\'s annoying. I like to appreciate algorithms as well as what the coder did to do it!
;)
This code can be optimized greatly. But as it is your first code, I won\'t tell you that it\'s badly coded. The note would then be \'Can Improve\'.
Here is another method of doing it:
On $@:Text:/^(([+-][vhoaq])\s(\S{2,}))/S::{
If ($nick == %owner) { MODE # $regml(2) $regml(3) }
Else { Notice $nick You can\'t tell me what to do, Fool. }
}
I hate \"|\" when I see how they\'ve been used here. :(
They can cause many stupid errors while there\'s simpler and clearer ways to do :).
So first issue, in the \'unset\' command, you wrote: \"unset goodbye\". Must be \"unset %goodbye\".
Second issue, for the sex thing, you refer to the file sex.ini to count and append but later refer to some ryanon.ini file to msg the number of times for the same thing ... That will definitely not work.
Not using pipes \"|\" would probably have avoided those errors ;).
Regards
Same as ^silk. Your snippet will never work for anyone except for you.
The reason is that you use a glabal variable %swear known only by you.
Here\'s another method.
;
On $@*:Text:/(BadWord1|BadWord2|BadWord3)/Si:#:{
If ($nick !isop $chan) { KICK $v2 $v1 Bad Word Detected }
}
;
The dollar \'$\' sign at the start of the event means \'allow regular expression match\'. This then permits to directly put the pattern in event declaration. I\'ll let you find out about $v1 and $v2. The /S option in the pattern means \'strip data before matching\'. :o)
/help on text
Regards