So, I previously asked this question:
http://stackoverflow.com/questions/2820234/can-someone-help-me-compare-using-f-over-c-in-this-specific-example-ip-address
I was looking at the posted code and I was wondering if this code could be written without it producing a warning:
let [|a;b;c;d|] = s.Split [|'.'|]
IP(parseOrParts a, parseOrP...
In "Programming F#" I came across a pattern-matching like this one (I simplified a bit):
let rec len list =
match list with
| [] -> 0
| [_] -> 1
| head :: tail -> 1 + len tail;;
Practically, I understand that the last match recognizes the head and tail of the list. Conceptually, I don't get why it works. As far as I understan...
I'm having some problems using sed in combination with html. The following sample illustrates the problem:
HTML="<html><body>ENTRY</body><html>"
TABLE="<table></table>"
echo $HTML | sed -e s/ENTRY/$TABLE/
This outputs:
sed: -e expression #1, char 18: unknown option to `s'
If I leave out the / from $TABLE so that it becomes <table><...
I wanted to trace for all functions in an erlang module, with dbg:tpl, but one of the internal functions took up 95% of the trace file. I then wanted to exclude only that single function and found that it was not as easy as I thought it would be.
I know there are great pattern matching possibilities for arguments when tracing.
Is ther...
Is it possible in OpenRasta to have a Uri pattern that allows for an array of values of the same key to be submitted and mapped to a handler method accepting an array of the query parameters.
Example: Return all the contacts named Dave Smith from a collection.
HTTP GET /contacts?filterBy=first&filterValue=Dave&filterBy=last&filterValue...
Look at the following string:
SELECT
column1 ,
column2, column3
FROM
table1
WHERE
column1 = 'text, "FROM" \'from\\\' x' AND
column2 = "sample text 'where' \"where\\\" " AND
( column3 = 5 )
I need to escape unnecessary white space characters from the string like:
removing white space from beginning and ending ...
Why does the following module not compile on Scala 2.8.RC[1,2]?
object Test {
import util.matching.Regex._
val pVoid = """\s*void\s*""".r
val pVoidPtr = """\s*(const\s+)?void\s*\*\s*""".r
val pCharPtr = """\s*(const\s+)GLchar\s*\*\s*""".r
val pIntPtr = """\s*(const\s+)?GLint\s*\*\s*""".r
val pUintPtr = """\s*(const\s+)?GLuint\s*\*\s*"...
I wonder if there is a good reason for this optical mismatch between e. g. pattern matching, which uses a simple
case foo =>
to denote that no action should be taken.
Wouldn't it be reasonable to have something like
import foo.bar.{Baz => }
instead of
import foo.bar.{Baz => _}
considering that _ is used as an "import everythin...
For example,
val list = List(1,2,3)
list match {
case a :: b =>
case _ =>
}
you can match head and tail of a List using :: or tokens of ParseResult using ~. What should I do to create class that can be matched like preceding classes?
UPD:
And have possibility to write:
case class @ ...
List(1,2,3,4) match {
case 1 @ 2...
On my site I use output buffering to grab all the output and then run it through a process function before sending it out to the browser (I don't replace anything, just break it into more manageable pieces). In this particular case, there is a massive amount of output because it is listing out a label for every country in the database (a...
Hello Everyone,
I am completely new to F# (and functional programming in general) but I see pattern matching used everywhere in sample code. I am wondering for example how pattern matching actually works? For example, I imagine it working the same as a for loop in other languages and checking for matches on each item in a collection. Th...
Hi Alls,
I would like to build a small python script that basicaly does the reverse of grep.
I want to match the files in a directory/subdirectory that doesn't have a "searched_string".
So far i've done that:
import os
filefilter = ['java','.jsp']
path= "/home/patate/code/project"
for path, subdirs, files in os.walk(path):
for ...
So for the string:
A large chicken, either thighs or breasts
I need a regex to match the term "chicken breast"
So it would be something like /chicken(.*?)breast/ would it not?
Thanks.
...
I'm encountering a situation where I'm using pattern matching for determining the visibility property of a column. System.Windows.Visibility has two fields, Visibility.Visible and Visibility.Collapsed. Can enyone tell me why the following code:
let colItem = myDataGrid.Columns.Item 1
chkBox.IsChecked <-
match colItem.V...
I'm trying to extract some specific pictures from html content . Currently I have the following array
[1] => Array
(
[0] => BuEZm5g!Wk~$(KGrHqQH-DgEvrb2CLuOBL-vbkHlKw~~_14.JPG#!BuEZm5g!Wk~$(KGrHqQH-DgEvrb2CLuOBL-vbkHlKw~~_12.JPG|1#http://i.ebayimg.com/08#!BuEZqMQBGk~$(KGrHqQH-DoEvrKYSoPiBL-vb)WgLw~~_14.JPG#!BuEZ...
I'm trying to recursively print out all an objects properties and sub-type properties etc. My object model is as follows...
type suggestedFooWidget = {
value: float ;
hasIncreasedSinceLastPeriod: bool ;
}
type firmIdentifier = {
firmId: int ;
firmName: string ;
}
type authorIdentifier = {
authorId: int ;
autho...
I'm trying to match a pattern into a string in XSLT/XPath using the matches function, as follows:
<xsl:when test="matches('awesome','awe')">
...
</xsl:when>
However, in both Firefox 3.5.9 and IE8, it doesn't show up. IE8 tells me that "'matches' is not a valid XSLT or XPath function." Is this due to XSLT 2.0 not being supported, an...
In scala.util.matching.Regex trait MatchData I see that there support for groupnames , I thought that this was related to (Regex Named Capturing Groups)
But since Java does not support groupnames until version 7 as I understand it (ref), Scala version 2.8.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6. gives me this exception:
scala>...
From what I understood I can use pattern-matching in a match ... with expression with tuples of values, so something like
match b with
("<", val) -> if v < val then true else false
| ("<=", val) -> if v <= val then true else false
should be correct but it gives me a syntax error as if the parenthesis couldn't be used:
File "oc...
Hello,
just a fast hint: I want to print a list of strings and I was going to do it by pattern matching just to get into this powerful functionality, how can I express the "do-nothing-but-return-unit" operation?
What I mean is
let print_nodes nodes =
match nodes with
[] -> (* here i want to noop *)
| s :: t -> print_string s;...