pattern-matching

Advice for algorithm choice

最后都变了- 提交于 2019-12-07 01:59:30
问题 I have to do a project that tries to scan the shape of the vehicles and detect what type of vehicle it is , the scanning will performed with a sensors called “vehicle scanner” they are just 50 beams of lights, each beam with receptor and emission as it is shown in the picture: I get from the sensors the raw sate of each beam (block or unblock) and with that continuous scanning we can create a probably very low res image of the vehicle. My question is what algorithms/technique I can use to

Pattern matching in a data frame context

我怕爱的太早我们不能终老 提交于 2019-12-07 01:52:01
问题 I have a data frame, the first 5 lines of which looks as follows: Sample CCT6 GAT1 IMD3 PDR3 RIM15 001 0000000000 111111111111111111111 010001000011 0N100111NNNN 01111111111NNNNNN 002 1111111111 111111111111111111000 000000000000 0N100111NNNN 00000000000000000 003 0NNNN00000 000000000000000000000 010001000011 000000000000 11111111111111111 004 000000NNN0 11100111111N111111111 010001000011 111111111111 01111111111000000 005 0111100000 111111111111111111111 111111111111 0N100111NNNN

Powershell find users expiring in 7 days

断了今生、忘了曾经 提交于 2019-12-07 01:49:05
问题 I am trying to run a powershell script that queries for accounts that expire within 7 days, I currently have $a = (get-date).AddDays(7) ; Search-ADAccount -AccountExpiring -TimeSpan "7" | Select-Object SamAccountName,AccountExpirationDate | Sort-Object AccountExpirationDate | Export-Csv 7_days.csv However when I make the following change, it seems to have some trouble and I end up getting an empty CSV file. Ultimately I want account expiring in 7 days, not more, not less. $a = (get-date)

How Match a Pattern in Text using Scanner and Pattern Classes?

烈酒焚心 提交于 2019-12-07 01:35:24
问题 i want to find whether a particular pattern exists in my text file or not. i m using following classes for this : java.util.regex.Pattern and java.util.Scanner; my sample text Line is String Line="DBREF 1A1F A 102 190 UNP P08046 EGR1_MOUSE 308 396"; and, i want to match following kind of pattern : A 102 190 where, at A's position a-z or A-Z but single charter. at 102's position any integer and of any length. at 190's position any integer and of any length. and,My code for pattern matching is:

PatternTest not optimized?

笑着哭i 提交于 2019-12-07 00:51:51
问题 In preparing a response to An unexpected behavior of PatternTest in Mathematica I came across an unexpected Mathematica behavior of my own. Please consider: test = (Print[##]; False) &; MatchQ[{1, 2, 3, 4, 5}, {x__?test, y__}] During evaluation of In[1]:= 1 During evaluation of In[1]:= 1 During evaluation of In[1]:= 1 During evaluation of In[1]:= 1 False Since, as Simon's quote of the documentation concisely states: In a form such as __?test every element in the sequence matched by __ must

Haskell - Pattern match(es) are overlapped

时间秒杀一切 提交于 2019-12-07 00:06:35
问题 test :: String -> String -> Int test' x y n = n test' "" (y:ys) n = error "error" test' (x:xs) "" n = error "error" test' (x:xs) (y:ys) n = if x == y then test' xs ys n else test' xs ys (n+1) test a b = test' a b 0 When I compile this, I get this output: Warning: Pattern match(es) are overlapped And the answer is always "0", which is not what I intended. What is the problem with the code and how to fix it? 回答1: test' x y n = n will match for every call, the other patterns won't be considered.

Scala Pattern Matching with Sets

梦想的初衷 提交于 2019-12-06 19:21:13
问题 The following doesn't work. object Foo { def union(s: Set[Int], t: Set[Int]): Set[Int] = t match { case isEmpty => s case (x:xs) => union(s + x, xs) case _ => throw new Error("bad input") } } error: not found: type xs How can I pattern match over a set? 回答1: Well, x:xs means x of type xs , so it wouldn't work. But, alas, you can't pattern match sets, because sets do not have a defined order. Or, more pragmatically, because there's no extractor on Set . You can always define your own, though:

How to read a file and extract data between multiline patterns?

本秂侑毒 提交于 2019-12-06 18:58:28
I have a file from which I need to extract one piece of data, delimited by (possibly) multiline fixed patterns some data ... [my opening pattern is here and can be multiline] the data I want to extract [my ending pattern which can be multiline as well] ... more data These patterns are fixed in the sense that the content is always the same, except that it can include new lines between words. The solution would be simple if I had the assurance that my pattern will be predictably formatted but do not. Is there a way to match such "patterns" to a stream? There is a question which is an almost

Haskell / GHC — is there any infix tag / pragma for “warn incomplete patterns”

人盡茶涼 提交于 2019-12-06 18:51:45
问题 I'm looking for a pragma that will warn on a particular incomplete pattern. It would make the compiler fail with the following (hypothetical) code: {-# FAILIF incomplete-patterns #-} f :: Int -> Int f 0 = 0 I am trying to write a "compiler" using Arrows, and knowing pattern matching is complete would help isolate bugs. Thanks! 回答1: You can require warnings, including incomplete patterns, with -Wall : {-# OPTIONS_GHC -Wall #-} module A where f :: Int -> Int f 0 = 0 Yielding: A.hs:6:1: Warning:

Clojure's substitute for Haskell's ADTs and pattern matching?

微笑、不失礼 提交于 2019-12-06 17:52:51
问题 Whenever in Haskell we need some variant data type, we would use ADTs in conjunction with pattern matching. What do Clojure folks use for such use cases? 回答1: Well, there are actually some pattern matching libraries written for Clojure. Clojure's macros make this sort of thing possible. Matchure is one of the most recent. There are even some stuff for ADTs in contrib. Disregarding that stuff, the closest thing we have to Haskell's ADTs in core Clojure is the new records and datatypes in