Handy F# snippets [closed]
Perl style regex matching let (=~) input pattern = System.Text.RegularExpressions.Regex.IsMatch(input, pattern) It lets you match text using let test = “monkey” =~ “monk.+” notation.
Perl style regex matching let (=~) input pattern = System.Text.RegularExpressions.Regex.IsMatch(input, pattern) It lets you match text using let test = “monkey” =~ “monk.+” notation.
Which reference-type you get depends on how you link the assembly. select the referenced assembly in the project-explorer go to the properties-page there you find a boolean flag “specific Version” true means: the assembly must have version=xxx false means: ignore the assembly version (I only have a german-vs2010 so the english translation for the german … Read more
I think some people simply prefer to read the declarations from right to left. const applies to the left-hand token, except when there is nothing there and it applies on the right-hand token. Hence const T& involves the “except”-clause and can perhaps be thought more complicated (in reality both should be as easy to understand). … Read more
This is a C++ feature. The code is valid and does exactly what it appears to do. Normally, a temporary object lasts only until the end of the full expression in which it appears. However, C++ deliberately specifies that binding a temporary object to a reference to const on the stack lengthens the lifetime of … Read more
../images/logo.png will move you back one folder. ../../images/logo.png will move you back two folders. /images/logo.png will take you back to the root folder no matter where you are/.
It cannot be done by Func but you can define a custom delegate for it: public delegate object MethodNameDelegate(ref float y); Usage example: public object MethodWithRefFloat(ref float y) { return null; } public void MethodCallThroughDelegate() { MethodNameDelegate myDelegate = MethodWithRefFloat; float y = 0; myDelegate(ref y); }
C++ references are intentionally not specified in the standard to be implemented using pointers. A reference is more like a “synonym” to a variable than a pointer to it. This semantics opens some possible optimizations for the compiler when it’s possible to realize that a pointer would be an overkill in some situations. A few … Read more
In C++ it’s very common what I consider an anti-pattern that uses const T& like a smart way of just saying T when dealing with parameters. However a value and a reference (no matter if const or not) are two completely different things and always and blindly using references instead of values can lead to … Read more
No, no, no, no; and yes, if you really need to count references you will have to do it manually. JS has no interface to this, GC, or weak references. Whilst you could implement a manual reference-counted object list, it’s questionable whether all the extra overhead (in performance terms but more importantly code complexity) is … Read more
A non-const reference cannot point to a literal. You cannot bind a literal to a reference to non-const (because modifying the value of a literal is not an operation that makes sense) and only l-values can be bound to references to non-const. You can however bind a literal to a reference to const. The “const” … Read more