Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


tufflax

Member Since 13 Jul 2005
Offline Last Active Apr 06 2015 04:47 PM

Posts I've Made

In Topic: I made a pattern matching tool, please help!

03 April 2015 - 07:19 PM

I usually use C#, and I don't use Java or Clojure, so I won't be able to actually try out your lib. It seems cool though - I like the idea of applying regular expression-style pattern matching to sequences and structured data instead of just text.

In C# normally we have a set of features called "LINQ" which can be used for processing sequences of data. They work more like what you'd see in a functional language:
 

// filters all log entries for one user and skips everything until the first error record.
var results = logEntries.Where(x => x.UserID == 12345).SkipWhile(x => x.EntryType != EntryType.Error);
The built-in LINQ functions provided in .Net don't have the power of regular expressions (as far as I know...), but it would be possible to implement a LINQ-compatible library that does, like yours. I think that would be pretty awesome.

 

 

There is an implementation of Clojure for .NET too, so it should be farily easy to port it. If anyone is really interested then let me know. And those LINQ operators looks like `filter` and `drop-while` in Clojure. Btw I highly recommend Clojure over Java and C#, it is really, really good. :P

(drop-while (fn [m] (not= (:entry-type m) :error))
            (filter (fn [m] (= (:user-id m) 12345)) log-entries)

In Topic: I made a pattern matching tool, please help!

03 April 2015 - 06:54 PM

I don't know Clojure, correct me if I'm wrong, but it seems that you can only search through hashmaps in memory.

 

Server logs are usually on disks, zipped, or in the cloud.  If you can have this library run on top of a hadoop cluster, redis, or some document-based database, then it can be more useful.

 

First of all, Clojure has lazy sequences, so it could pretty easily be read bit by bit from disk and process it. Same with zips I guess. It can also fairly easily be used together with Cascalog http://cascalog.org/ which is a declarative language for use on Hadoop. I have done it before but don't have it installed right now. I could also extend it to data types other than hashmaps. Just need to come up with a good syntax for everything.


In Topic: I made a pattern matching tool, please help!

02 April 2015 - 01:27 PM

@Nypyren (is this doing something? :P)

 

Right now it can not be used recursively, but it would be pretty easy to implement I think, if I could just decide on a good syntax for it. Same with the error|warning. But in that case, since Clojure has pretty convenient function literals (for example #(> % 3) is a function that checks whether the input is larger than 3) something like {event-type: #(contains? [error warning] %)} could be used if I made functions as values be applied as predicates. I'm not up to date with Java, but it's getting lambdas too, right?

 

In your last example, yes, piping the results to a next step seems easiest, and something that seems perfectly acceptable.


In Topic: Any way to make this simple tennis game more OO?

26 April 2014 - 12:42 PM

This is all you need: http://www.infoq.com/presentations/Simple-Made-Easy


In Topic: Catching illegal movement with partial data

15 April 2014 - 02:27 PM

I see. Still, 60 updates per second seems like a lot, hmm...

 

Thanks guys! You have given me things to think about.


PARTNERS