I have string with accepted file's extensions. Something like "JPG,PNG,TXT". String can be whatever I want. I am using Reactive Extensions, so i filter files by using Where(). For now i am using
Where(e => e.FullPath.Contains(filtering)
But it only works, when there is only 1 extension. Any idea how to make it dynamically? Where will be call only once! I write in c#.
This looks to be a LINQ question rather than javascript(rxjs). However, as LINQ seems to be comparable with array methods in js I shall attempt to answer.
First convert the string of extensions into an array. This only needs to be done once:
filterExtensions = filtering.Split(',');
Then the condition would be:
Where(e => filterExtensions.Any(
extension => e.FullPath.Contains(extension)
))
This question already has answers here:
Preferred method for viewing code generated by Template Haskell
(3 answers)
Closed 6 years ago.
I created Data with a help of Template Haskell. I use it from another program by $(code here).
So, can I convert Data to .hs file? I want to see the structure of Data.
One common way to do this is to write you normal Haskell code that uses the template Haskell and then feed GHC the option -ddump-splices and -ddump-to-file to have it output a file containing all of your original code but with the template Haskell expanded so you can see exactly what is being compiled.
Another option if you want to not see the full file is to use the pretty printer that comes with the template-haskell package. The module contains a number of helper functions for constructing a Doc which may then be rendered to a string with pprint :: Doc -> String and outputted using the IO features of the Q monad.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Annoying PHP error: “Strict Standards: Only variables should be passed by reference in”
I have this line of code,
$extension=end(explode(".", $srcName));
when I fun my function I get
PHP Strict Standards: Only variables should be passed by reference in
I am not sure how to solve this
The function end() requires a variable to be passed-by-reference and passing the return-value of a function doesn't acheive this. You'll need to use two lines to accomplish this:
$exploded = explode(".", $srcName);
$extension = end($exploded);
If you're simply trying to get a file-extension, you could also use substr() and strrpos() to do it in one line:
$extension = substr($srcName, strrpos($srcName, '.'));
Or, if you know the number of .'s that appear in the string, say it's only 1, you can use list() (but this won't work if there is a dynamic number of .'s:
list(,$extension) = explode('.', $srcName);
I am coding a plugin for autodesk 3dsmax and they recommend to use the _T(x) macro for every string literal to make it work with unicode as well. I am using the stl string class a lot in this code. So do I have to rewrite the code: string("foo") to: string(_T("foo")) ? Actually the stl string class doesnt have a constructor for wchars, so it doesnt make sense, does it?
Thx
Look at the definition of "T" macro - it expands to "L" in "Unicode" builds or nothing in "non-Unicode" builds. If you want to keep using the string calss and follow the recommendation for your plugin, your best bet is to use something like tstring which would follow the same rules.
But the truth is - all this "T" business made a lot of sense 10 years ago - all modern Windows versions are Unicode-only and you can just use wstring.
You could create an own string class say xstring and use the _T for constants and then internally, depending on unicode or not switch to string or wstring. either that or instantiate xstring<yourchartype>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've just had a discussion with a developer about naming classes in C#. My final throw away line was, "Let's not put any emoticons in our class names."
I can't think of a way you could put emoticons in C# class names, but I haven't thought too hard about it. Is this possible?
Does any programming language allow it? What would be the best/worst language to be able to perform this in?
Update: The Scheme answer bests answers my question. It was a quick idea after a quick discussion so I'm going to accept after a short amount of time and then move on with my life. Thanks for the responses.
Many Japanese-style emoticons - O_o, v_v and the like - are perfectly legal substrings of identifier names in most languages.
For example in Scheme you have the flexibility to include symbols like :, -, / ... in the names,
(define (:-D x)
(+ x 1))
...
(:-D 9)
output: 10
C# supports any Unicode letter for identifiers, so if you find some suitable for emoticons in the Unicode tables, you can use them. The CLR itself allows far more characters in identifier names, like the typical backtick used in compiler-generated names, so you could get really crazy by defining really strange names in MSIL, and then loading the classes with reflection in C# because it does not support those characters...
The method name oO comes to mind. It's an emoticon in itself (small and large eye), but when called on a reference, it expands to a thought bubble: .oO(Hello).
Slightly off-topic: I was processing filenames the other day and realised that all sorts of faces had appeared in my code:
string number(fn.begin()+fn.rfind('_')+1,fn.begin()+fn.rfind('.'));
And of course there are the right-to-left emoticons you almost always get at the end of lines of C++ code:
mesh->Delete();
Why does C++ look so sad?
In C++, if you name a class/struct _ (a poor decision, but here we go), you can derive from it like this:
struct emoticon_to_the_right_of_this :_{
};
Thinking about this, a class o might be just as good:
struct another_emoticon_to_the_right_of_this :o{
};
Hm. I seem to only come up with sad ones. Is that Freud guy around here today? I do have a question to ask him...
Perl uses :: as a package name separator, which means that an IM client might decide to insert a smiley when I talk about XML::Parser (contains ":P") or Data::Dumper (contains ":D"). Punctuation other than :: isn't recommended in package names, so most "extended" smileys are out of the picture, but if I wanted to be very silly I could reference a variable named ${ ':-)' } -- but it would always have to be referenced using the ${'...'} syntax since it's not a recognizable identifier name :)
At this moment in 2014, Apple have just released Swift yesterday. And I made a short example for this. It compiles and runs perfectly fine. :D
I believe I've seen languages that use => to access object attributes (something like person=>father)
It's not actually part of the name, but it could be an emoticon.
Not strictly class names, but there are a few that pop up in PHP from time to time, like an underscore in single quote when concatenating:
$foo = $bar.'_'.$baz;
And as someone else pointed out, you don't even really need special symbols for some of them:
class o_0 {}
class v_v {}
class T_T {}
Something more convoluted:
function d() { echo 'Thumbs up!!'; }
d('_');