Isn't this a bit strange?
String.count("","");
(9) Result: 1
String.count(" ","");
(10) Result: 0
String.count(" ","");
(11) Result: 1
String.count(" ","");
(12) Result: 2
I could understand the series {1,2,3,4}, {-1,0,1,2} and {0,0,1,2} though.
It should be {1,2,3,4}.
'String.count(foo,foo);' must always return 1.
/ Hedda (Hemma igen)
Previous text:
2003-04-29 01:50: Subject: Strange?
Isn't this a bit strange?
String.count("","");
(9) Result: 1
String.count(" ","");
(10) Result: 0
String.count(" ","");
(11) Result: 1
String.count(" ","");
(12) Result: 2
I could understand the series {1,2,3,4}, {-1,0,1,2} and {0,0,1,2} though.
/ Martin Nilsson (har bott i google)
I think this should hold:
String.count (a, b) == sizeof (a / b) - 1
Looks like the current implementation is some sort of compromise between your assertion and the above.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-04-29 02:11: Subject: Strange?
It should be {1,2,3,4}.
'String.count(foo,foo);' must always return 1.
/ Hedda (Hemma igen)
Yes, and String.count(" ","") should be 3, since the empty string occurs at three distinct positions in the string (0, 1 and 2). So I agree with this sequence.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-29 02:11: Subject: Strange?
It should be {1,2,3,4}.
'String.count(foo,foo);' must always return 1.
/ Hedda (Hemma igen)
Did you read what I wrote. Of course there can be an infinite amount of empty string between two characters, but _they will all have the same position_. The number of DISTINCT POSITIONS (I'm writing it in allcaps this time in hope that you actually read it) is finite, and in this case 3.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-29 02:17: Subject: Strange?
From a mathematical point of view that argument is rediculus. It is plain obvious that there can be an infinite amount of empty strings between two whitespaces.
/ Peter Lundqvist (disjunkt)
=)
Well.. how many DISTINCT POSITIONS are there between two empty strings?
(Yes, I'm kidding - I must av skimmed pass the bit about distinct positions).
/ Peter Lundqvist (disjunkt)
Previous text:
2003-04-29 02:19: Subject: Strange?
Did you read what I wrote. Of course there can be an infinite amount of empty string between two characters, but _they will all have the same position_. The number of DISTINCT POSITIONS (I'm writing it in allcaps this time in hope that you actually read it) is finite, and in this case 3.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Since positions are relative to a particular string, there can of course be no positions "between" two strings, empty or not.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-29 02:24: Subject: Strange?
=)
Well.. how many DISTINCT POSITIONS are there between two empty strings?
(Yes, I'm kidding - I must av skimmed pass the bit about distinct positions).
/ Peter Lundqvist (disjunkt)
Sorry - I was unclear. I was speaking of strings in a more abstract maner - not as pike strings. Which, of course, makes my argument even more dumbstruck since there is little point in talking of string length in that case (strings are, however, another matter).
/ Peter Lundqvist (disjunkt)
Previous text:
2003-04-29 02:27: Subject: Strange?
Since positions are relative to a particular string, there can of course be no positions "between" two strings, empty or not.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
This is a programming language, not math.
First you might want to do a count to see how many places there are that you should do a replace on:
replace("foo", "", "bar");
Result: "fbarobaro"
Which of course should have been:
replace("foo", "", "bar");
Result: "barfbarobarobar"
Why? Well, just because returning "counting empty string in other string" error, isn't that useful and it makes program harder to write if you always have to check the string and see if it is "".
/ Hedda (Hemma igen)
Previous text:
2003-04-29 02:17: Subject: Strange?
From a mathematical point of view that argument is rediculus. It is plain obvious that there can be an infinite amount of empty strings between two whitespaces.
/ Peter Lundqvist (disjunkt)
Why? Well, just because returning "counting empty string in other string" error, isn't that useful
Good point.
/ Peter Lundqvist (disjunkt)
Previous text:
2003-04-29 02:23: Subject: Strange?
This is a programming language, not math.
First you might want to do a count to see how many places there are that you should do a replace on:
replace("foo", "", "bar");
Result: "fbarobaro"
Which of course should have been:
replace("foo", "", "bar");
Result: "barfbarobarobar"
Why? Well, just because returning "counting empty string in other string" error, isn't that useful and it makes program harder to write if you always have to check the string and see if it is "".
/ Hedda (Hemma igen)
Which of course should have been:
replace("foo", "", "bar");
Result: "barfbarobarobar"
That was not a suggestion. Now replace(a,b,c) is the same as a/b*c, which is OK too.
/ Hedda (Hemma igen)
Previous text:
2003-04-29 02:23: Subject: Strange?
This is a programming language, not math.
First you might want to do a count to see how many places there are that you should do a replace on:
replace("foo", "", "bar");
Result: "fbarobaro"
Which of course should have been:
replace("foo", "", "bar");
Result: "barfbarobarobar"
Why? Well, just because returning "counting empty string in other string" error, isn't that useful and it makes program harder to write if you always have to check the string and see if it is "".
/ Hedda (Hemma igen)
pike-devel@lists.lysator.liu.se