using a twitter display widget and need to add links to the hash tags. so i need a pattern replacement, replacing each string that starts with a hash/pound sign and ends in a space with the twitter search link. i am pretty clumsy w/jquery--can someone point me in the right direction -- thanks, anyone!
something taking me:
// FROM:
<ul ...
I'm writing a simple little ocaml program that reads an algebraic statement in from a file, parses it into an AST using ocamllex/ocamlyacc, reduces it, and then prints it. The part where I'm reducing the expression seems a bit... ugly. Is there any way I can simplify it?
(* ocaml doesn't seem to be able to take arithmetic operators
a...
I'm doing matching against some case classes and would like to handle two of the cases in the same way. Something like this:
abstract class Foo
case class A extends Foo
case class B(s:String) extends Foo
case class C(s:String) extends Foo
def matcher(l: Foo): String = {
l match {
case A() => "A"
case B(sb) | C(sc) => "B"
...
Hello.
I'm having a problem trying to understand how does AIML pattern matching works.
What's the difference between _ and *? And how I should use them to get the best match?
I have this document only, but it lacks some good examples.
...
Hi! I'm trying to find a way to match a query to a regular expression in a database. As far as I can tell (although I'm no expert), while most DBMS like MySQL have a regex option for searching, you can only do something like:
Find all rows in Column 1 that match the regex in my query.
What I want to be able to do is the opposite, i.e.:...
Is it possible to use wild cards between terms in a pattern? for example, if I want to answer the question, "How much are overdue fines on my books?" is there a way to use a wild card between the terms "overdue" and "books?"
...
I have an algorithm that returns a list of classifications(strings) dependant on the two arguments given to the algorithm: a type variable, and an extra category string that allows certain special classifications to be added to the result list.
The current implementation, is unreadable and unscalable due to the expression of the rules a...
text text text
text text text
{test}
content
content
content
{/test}
text text text
text text text
i need to get two separate results from the above string:
1.
{test}
content
content
content
{/test}
2.
content
content
content
so, what should be the two separate regular expression patterns for...
If SomeType is defined as:
data SomeType = X {myBool :: Bool}
| Y {myString :: String}
| Z {myString :: String}
and I will update an arbitrary X, dependent of his type as follows:
changeST :: SomeType -> SomeType
changeST (X b) = (X True)
changeST (Y s) = (Y "newString")
changeST (Z s) = (Z "newStrin...
consider, in my javascript i am getting :
function callBack_Show(result) {
//where result is in jsonp format
var artical= result.Artical;
now artical contains some text,
i want to read number of words and characters in it and display them
the words can be separated by: blank space, fullstop,comma etc
and i want to do it in same java...
I'm still a Scala noob, and this confuses me:
import java.util.regex._
object NumberMatcher {
def apply(x:String):Boolean = {
val pat = Pattern.compile("\\d+")
val matcher = pat.matcher(x)
return matcher.find
}
def unapply(x:String):Option[String] = {
val pat = Pattern.compile("\\d+")
val matcher = pat.matche...
I tried to create an unapply method to use in pattern matching, and I tried to make it return something different than Option, however, Eclipse shows that as an error. Is it a rule that unapply must return an Option[T] ?
EDIT: here's the code I'm trying to use. I switched the code from the previous section so that unapply returns a Bool...
I am working on a real estate website and i would like to write a program that
can figure out(classify) if an image is a floor plan or a company logo.
Since i am writing in php i will prefer a php solution but any c++ or opencv solution will be fine as well.
Floor Plan Sample:
Logo Sample:
...
I will be tackling a Java (GWT) project soon (related question). Maybe I am trying to stretch things here but I was wondering if there is any "pattern matching framework" (don't really know if there is a term for this) written in Java? (maybe it is my prolonged exposure to Erlang that twists my thoughts around patterns all the time :-)
...
When I'm programming in Erlang should I be validating all return values from function calls for success via pattern matching even if i don't intend to use the return value? Most Erlang APIs I've seen so far don't throw exceptions on error (but return something like {error, Error}) so I must need to validate the return value yes? Any exce...
I want to search some memory range for a specific byte pattern. Therefore, my approach is to build a function
void * FindPattern (std::vector<byte> pattern, byte wildcard,
void * startAddress, void * endAddress);
using the Boyer-Moore-Horspool algorithm to find the pattern in the memory range.
The wildcard byte stays for some sp...
I've been studying Haskell in my spare time and have recently crossed into the area of monadic functions. I've distilled the code from an excercise I've been working on into this very contrived example to isolate the exact problem I'm having:
import System.Random
rndPermu :: [a] -> IO (a, [a])
rndPermu xs = (front, back)
where (fro...
Anyone know what the problem with this code is?
let rec Foo(a,b) =
match a () with
| None -> Some(b)
| Some(c) -> Some(Foo(c,b))
Here's the compiler error:
"Type mismatch. Expecting a 'a but given a 'a option The resulting type would be infinite when unifying ''a' and ''a option'"
...
Why does this print wtf? Does pattern matching not work on structural types?
"hello" match {
case s: { def doesNotExist(i: Int, x: List[_]): Double } => println("wtf?")
case _ => println("okie dokie")
}
...
I don't understand why the following case doesn't match. Null should be an instance of Any, but it doesn't match. Can someone explain what is going on?
val x = (2, null)
x match {
case (i:Int, v:Any) => println("got tuple %s: %s".format(i, v))
case _ => println("catch all")
}
prints catch all
Thanks.
...