|
2 weeks ago I asked advice on a graphics card. I wanted to upgrade my Nvidia Geforce GTX 460.
In meantime I successfully installed …
[ drum rolls ]
[ more drum rolls ]
An Nvidia GeForce RTX 2060 …
It was a bit above my budget, but it should last me quite some time.
(now to find some good games... )
|
|
|
|
|
Congrats, would be my choice too!
|
|
|
|
|
V. wrote: now to find some good games...
I am lately enjoying Destiny 2. But it works pretty good on my machine in standard settings, but I suppose it won't be a big deal for your brand new graphic card...
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.
|
|
|
|
|
My kid bought a 2080 Super and then we had to build a whole new system around it.
|
|
|
|
|
Consider lists in English
var c = list.Count;
var result = new StringBuilder();
if(0<c) {
var delim = "";
foreach (var item in list)
{
result.Append(delim);
if (1 == c)
result.Append("or ");
result.Append(item);
delim = ", ";
--c;
}
} else if(0==c) {
result.Append(list[0]);
}
I mean, it's not as awkward as say, a blind date but it's still pretty kludgy.
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 17-Dec-19 23:30pm.
|
|
|
|
|
Mm... your code does confuses me so much indeed...
I ignored it and followed the comment instead, how about?
for (int i = 0; i < list.Count; i++)
{
if (i > 0)
{
result.Append(", ");
if (i == list.Count - 1)
result.Append("or ");
}
result.Append(list[i]);
}
I find this simple, readable with clear intention, if I do say so myself!
Clarity over (often misguided) micro optimisation
|
|
|
|
|
part of the problem is that was a quick port from my actual code which uses a hashset instead of a list and so doesn't allow indexing. foreach complicates 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.
|
|
|
|
|
var list = new HashSet<object>() { };
var result = new StringBuilder();
int count = 0;
foreach (var item in list)
{
if (count++ > 0)
{
result.Append(", ");
if (count == list.Count - 1)
result.Append("or ");
}
result.Append(item);
}
return result.ToString();
|
|
|
|
|
yeah yeah.
although your postfix increment inside the expression like that could be more clear by moving it outside the expression.
Adding, in my final code i actually special case for 2 items as well "apple or pear" sans comma, like that.
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 find
count++;
if (count > 1)
{
result.Append(", ");
if (count == list.Count)
result.Append("or ");
}
less obvious to read, since if (count > 1) really mean first iteration.... (which would be nicer with a zero)
|
|
|
|
|
A matter of taste I suppose.
I'm trying a little something different with parser generation this go round.
I'm making one that generates a recursive descent parser.
so like, your rules get baked out into recursive descent routines like this, instead of table driven code:
Makes it easy to put code into it.
private static ParseNode _ParseBoolean(ParserContext context) {
ParseNode result = null;
if ((JsonParser.@true == context.SymbolId)) {
ParseNode[] children = new ParseNode[1];
children[0] = new ParseNode(JsonParser.@true, context.Value);
context.Advance();
return new ParseNode(JsonParser.Boolean, children);
}
if ((JsonParser.@false == context.SymbolId)) {
ParseNode[] children = new ParseNode[1];
children[0] = new ParseNode(JsonParser.@false, context.Value);
context.Advance();
return new ParseNode(JsonParser.Boolean, children);
}
context.Error("Expecting true or false");
return null;
}
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.
|
|
|
|
|
Nice, keep it up!
|
|
|
|
|
honey the codewitch wrote: context.Error("Expecting true or false");
Are you already programming with Q-Bits?
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.
|
|
|
|
|
2nd option, perhaps to your liking, but really slower, using more memory, less readable
but it does avoid the local count variable
var list = new HashSet<object>() { };
var result = new StringBuilder();
foreach (var item in list)
{
if (result.Length > 0)
result.Remove(result.Length - 3, 3);
result.Append(item);
result.Append(",or ");
}
return result.ToString();
|
|
|
|
|
now you're just being a smart ass.
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.
|
|
|
|
|
The real problem is the insistence on infix notation in English. If lists were written as "Apple, pear, banana OR", the meaning would be perfectly clear. It would also lend itself to more complex constructs.
Unfortunately, I know of no human language that uses similar syntax.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
that just gave me a potential idea.
Swap that last word and the notation such that they change places.
Apple, banana, or pear becomes Apple, banana, pear, or
and you have your fix.
Although I'd very much prefer
Or, apple, banana, pear
from a parsing standpoint
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.
|
|
|
|
|
Hahah, only now, reading this last message, I understand how English is making the list confusing, hahah!
|
|
|
|
|
Consider the LDAP way.
|( apple , banana , pear )
|
|
|
|
|
or the programming way
(apple | banana | pear)
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
I should add, no it's humans. Mixtec has constructs in it that would make your head spin. Like what they classify as "round things" is incomprehensible. Laundry detergent is round. AND THEY ALL HAVE PRONOUNS. So you have to know what's what. Also the language has way more verbs than nouns, such that you can't tell what kind of bag someone has except by describing how they're carrying it.
Also they don't have a word for smile.
Humans are ridiculous.
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.
|
|
|
|
|
Quote:
else if(0==c) {
result.Append(list[0]);
} An empty list will now produce an ArgumentOutOfRangeException .
This should work with any IEnumerable list:
public static string JoinList<T>(this IEnumerable<T> list, string delimiter = ", ", string finalDelimiter = "or ")
{
int count = list.Count();
switch (count)
{
case 0:
{
return string.Empty;
}
case 1:
{
return Convert.ToString(list.First());
}
default:
{
int index = count;
var result = new StringBuilder();
foreach (var item in list)
{
if (result.Length != 0) result.Append(delimiter);
if (index == 1) result.Append(finalDelimiter);
result.Append(item);
--index;
}
return result.ToString();
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The Oxford comma (i.e. the comma before "and" or "or") is a style choice and optional.
In any event, assuming all elements of the list are unique, the solution is the same:
With comma:
var result = new StringBuilder();
list.ForEach(item => result.Append(item).Append(item == list.Last() ? "" : item == list.Take(list.Count - 1).Last() ? ", or " : ", "));
Or without comma:
var result = new StringBuilder();
list.ForEach(item => result.Append(item).Append(item == list.Last() ? "" : item == list.Take(list.Count - 1).Last() ? " or " : ", "));
|
|
|
|
|
I'd never create that many objects to solve such a mundane problem unless I was doing business dev.
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.
|
|
|
|
|
Guess what I do?
Actually, as I wrote it, I did wonder about how efficient it is!
I don't think it creates that many objects; I think Take just builds a new List referencing the original elements. Last definitely just references the last element and doesn't copy it.
|
|
|
|