|
No display, you have to learn specific movements with your fingers to get a particular character to type. I think it is a ridiculous idea too.
|
|
|
|
|
voice recognition would be better..
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
If you stir a little coconut oil into your kale it makes it easier to scrap into the trash.
Ok I'm bored, I know the way out!
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
Interestingly, in Dutch "kale" means bald-headed
|
|
|
|
|
RickZeeland wrote: Interestingly, in Dutch "kale" means bald-headed
A little coconut oil might help with that also...make it shine!
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
|
Mike Hankey wrote: Ok I'm bored, I know the way out! don't forget your coat
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
No need for a coat on a day like this. Currently 33C, or 40 with the humidity. In Canada, y'know, the frozen wasteland. I'm having a hard time with my igloo.
|
|
|
|
|
Nelek wrote: don't forget your coat
and your coconut oil.
|
|
|
|
|
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
Do you ever hate yourself a little for the code you write?
I'm writing some extremely destructive code at the moment
IList<IList<string>> _Explode(IList<IList<string>> left, IList<IList<string>> right)
{
if (right.IsNullOrEmpty())
return left;
else if (left.IsNullOrEmpty())
return right;
var result = new List<IList<string>>();
foreach (var leftList in left)
{
foreach (var rightList in right)
{
var finalList = new List<string>();
finalList.AddRange(leftList);
finalList.AddRange(rightList); ;
if (!result.Contains(
finalList,
OrderedCollectionEqualityComparer<string>.Default))
result.Add(finalList);
}
}
return result;
}
Its job apparently is to work my CPU like a rented mule while it eats up all my ram.
I am microsoft.
EDIT:
After some suggestions in the comments, it didn't make a big difference overall but I removed every foreach and added preallocation to the lists. Comments removed for brevity
IList<IList<string>> _Explode(IList<IList<string>> left, IList<IList<string>> right)
{
if (null== right||0==right.Count)
return left;
else if (null==left||0==left.Count)
return right;
var result = new List<IList<string>>();
for(int ic=left.Count,i=0;i<ic;++i)
{
var leftList = left[i];
for(int jc=right.Count,j=0;j<jc;++j)
{
var rightList = right[j];
var finalList = new List<string>(ic+jc);
for(int kc=leftList.Count,k=0;k<kc;++k)
finalList.Add(leftList[k]);
for (int kc = rightList.Count, k = 0; k < kc; ++k)
finalList.Add(rightList[k]);
var oec = OrderedCollectionEqualityComparer<string>.Default;
var found = false;
for (int kc = result.Count, k = 0; k < kc; ++k)
{
if (oec.Equals(result[k], finalList))
{
found = true;
break;
}
}
if(!found)
result.Add(finalList);
}
}
return result;
}
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
modified 19-Jul-19 12:24pm.
|
|
|
|
|
Why are left and right of type IList<string> ? Should the caller expect their contents to be mutable? It seems they should of type IEnumerable<string> .
#BetterLivingThroughSafeCode
/ravi
|
|
|
|
|
You're absolutely right, but unfortunately .NET's generics are not covariant.
So I could not pass a
List<IList<string>> to something that took
IEnumerable<IEnumerable<string>> or even
IList<IEnumerable<string>> - it doesn't fly.
If .NET's covariance worked more like C++'s I'd have done like you suggested.
But as it is, utility beats theory at the end of the day.
I think of it as a workaround for a limitation of .NET
The other option is to copy them but this method is resource hungry enough
Fortunately, grotty as it is, it's a private method.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
modified 19-Jul-19 11:29am.
|
|
|
|
|
codewitch honey crisis wrote: So I could not pass a
List<IList<string>> to something that took
IEnumerable<IEnumerable<string>> Yes you can.
Generic covariance | C# Online Compiler | .NET Fiddle[^]
codewitch honey crisis wrote: or even
IList<IEnumerable<string>> That one won't work, because IList<T> is invariant on T .
But you could pass it to something that expected an
IReadOnlyList<IEnumerable<string>>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i just tried that. my mistake. is this new? the rules for generic covariance i thought i was going by were published back in the 2.0 days. I assumed it hadn't really changed. Or maybe it always worked and I misunderstood it or misremembered it later. Oh well. Thanks.
I probably won't use IReadOnlyList because it's too much churn in my code. If this were a public method I'd consider it.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Generic co- and contra-variance[^] were first added in .NET 4.0, so your example wouldn't have worked in 2.0.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That explains why i didn't know. I left the field professionally prior to the wide adoption of .NET 4.
What a cool feature to add. I'll have to remember that. Thanks for that, and the link.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Ugh, try using for rather than foreach.
|
|
|
|
|
i don't think a couple of spurious enumerator creations are the real perf bottleneck here.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I've said it before and I'll copy/paste it again:
"
always remember and never forget that the readability of foreach comes at the cost of being slower than for -- that really is a 20x difference
"
YMMV
|
|
|
|
|
in my experience the 20x difference comes when you're doing lots and lots of nested foreach operations, like doing a ton of functional style queries, due to the heap pressure of all those object creation and destructions.
in truth, that function was whipped together in a few minutes so I just didn't bother with for loops.
I only think about performance in terms of linear vs log times - basically mathematical complexity of functions.
Beyond that, I profile. So for code like this it gets changed if and when it needs to be.
However, given the nested nature of this call it is probably best to change it to for loops early on.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
One quick improvement: pre-allocate the inner List<string> to the correct size:
var finalList = new List<string>(leftList.Count + rightList.Count);
That way, it doesn't have to dynamically reallocate the backing array every time it runs out of space.
(It probably won't make a huge difference when you're calling AddRange with something that implements ICollection<T> , but every little helps.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i tried that, and it didn't change things. I think it's because the list sizes are usually only one or two elements and the min starting capacity is higher than that.
At least with ArrayList i remember it being something like 16 but I don't remember looking at List's sourcecode or disassembly so I couldn't say.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Add a Thread.Sleep in the inner loop to cool things down a bit.
|
|
|
|
|
I think my better option is to reduce the number of times I'm calling it. =)
and probably split it across multiple cores
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|