annotate paste/paste.14186 @ 12246:f3be034784d0 draft

<b_jonas> addwhatis brachylog(1egobot) - Brachylog, a Prolog-like golf language
author HackEso <hackeso@esolangs.org>
date Thu, 05 Dec 2019 23:44:34 +0000
parents e037173e0012
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
1 import System.Environment
e037173e0012 Initial import.
HackBot
parents:
diff changeset
2 import System.Process
e037173e0012 Initial import.
HackBot
parents:
diff changeset
3 import System.Exit
e037173e0012 Initial import.
HackBot
parents:
diff changeset
4 import Control.Monad
e037173e0012 Initial import.
HackBot
parents:
diff changeset
5 import Control.Applicative
e037173e0012 Initial import.
HackBot
parents:
diff changeset
6 import Data.List
e037173e0012 Initial import.
HackBot
parents:
diff changeset
7
e037173e0012 Initial import.
HackBot
parents:
diff changeset
8 main = do
e037173e0012 Initial import.
HackBot
parents:
diff changeset
9 r <- buildRegex . permuteArgs <$> getArgs
e037173e0012 Initial import.
HackBot
parents:
diff changeset
10 (_, _, _, h) <- createProcess (proc "/hackenv/bin/log" [r])
e037173e0012 Initial import.
HackBot
parents:
diff changeset
11 exitWith <$> waitForProcess h
e037173e0012 Initial import.
HackBot
parents:
diff changeset
12 where
e037173e0012 Initial import.
HackBot
parents:
diff changeset
13 permuteArgs = permutations . join . map words
e037173e0012 Initial import.
HackBot
parents:
diff changeset
14 buildRegex = oBrackets . intercalate ".*" . map (iBrackets . intercalate "|")
e037173e0012 Initial import.
HackBot
parents:
diff changeset
15 iBrackets s = "(?:" ++ s ++ ")"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
16 oBrackets s = "^.*(?:" ++ s ++ ").*$"