Java 8 Pattern Matching?

I suppose you are not talking about pattern matching in the sense of applying a regular expression on a string, but as applied in Haskell. For instance using wildcards: head (x:_) = x tail (_:xs) = xs Java 8 will not support that natively, with Lambda expression there are, however, ways to do so, like … Read more

Difference between * and node() in XSLT

<xsl:template match=”node()”> is an abbreviation for: <xsl:template match=”child::node()”> This matches any node type that can be selected via the child:: axis: element text-node processing-instruction (PI) node comment node. On the other side: <xsl:template match=”*”> is an abbreviation for: <xsl:template match=”child::*”> This matches any element. The XPath expression: someAxis::* matches any node of the primary node-type … Read more

Hungarian Algorithm: finding minimum number of lines to cover zeroes?

Update I have implemented the Hungarian Algorithm in the same steps provided by the link you posted: Hungarian algorithm Here’s the files with comments: Github Algorithm (Improved greedy) for step 3: (This code is very detailed and good for understanding the concept of choosing line to draw: horizontal vs Vertical. But note that this step … Read more

Pattern matching functions in Clojure?

There is ongoing work towards doing this with unification in the core.match ( https://github.com/clojure/core.match ) library. Depending on exactly what you want to do, another common way is to use defmulti/defmethod to dispatch on arbitrary functions. See http://clojuredocs.org/clojure_core/clojure.core/defmulti (at the bottom of that page is the factorial example)

Finding words after keyword in python [duplicate]

Instead of using regexes you could just (for example) separate your string with str.partition(separator) like this: mystring = “hi my name is ryan, and i am new to python and would like to learn more” keyword = ‘name’ before_keyword, keyword, after_keyword = mystring.partition(keyword) >>> before_keyword ‘hi my ‘ >>> keyword ‘name’ >>> after_keyword ‘ is … Read more

Recursive listing of all files matching a certain filetype in Groovy

This should solve your problem: import static groovy.io.FileType.FILES new File(‘.’).eachFileRecurse(FILES) { if(it.name.endsWith(‘.groovy’)) { println it } } eachFileRecurse takes an enum FileType that specifies that you are only interested in files. The rest of the problem is easily solved by filtering on the name of the file. Might be worth mentioning that eachFileRecurse normally recurses … Read more

Compare Python Pandas DataFrames for matching rows

One possible solution to your problem would be to use merge. Checking if any row (all columns) from another dataframe (df2) are present in df1 is equivalent to determining the intersection of the the two dataframes. This can be accomplished using the following function: pd.merge(df1, df2, on=[‘A’, ‘B’, ‘C’, ‘D’], how=’inner’) For example, if df1 … Read more

tech