Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated examples.

  • Loading branch information...
commit 0ebad845ba009f91b1976425134652f8c2d6a147 1 parent 7e0a0bf
@leepike authored
Showing with 33 additions and 6 deletions.
  1. +9 −1 Examples/Languages.hs
  2. +16 −5 Examples/Sat.hs
  3. +8 −0 Examples/Test.hs
View
10 Examples/Languages.hs
@@ -6,7 +6,7 @@
{-# LANGUAGE RebindableSyntax #-}
-module Languages where
+module Languages (languages) where
import Language.Copilot
import qualified Prelude as P
@@ -156,6 +156,14 @@ copyAccept = do
++ 0 -- don't care about part of
-- stream after ++
+---------------------------------------------------------------------------------
+
+languages :: IO ()
+languages = do
+ interpret 20 reAccept
+ interpret 20 (cfAccept 10)
+ interpret 20 (csAccept 10)
+ interpret 20 copyAccept
---------------------------------------------------------------------------------
-- -- Recognize the language of arbitrarily long sequence of prime numbers.
View
21 Examples/Sat.hs
@@ -3,7 +3,7 @@
-- {-# LANGUAGE RebindableSyntax #-}
-module Languages where
+module Sat where
import Language.Copilot
import qualified Prelude as P
@@ -41,16 +41,27 @@ satSpec f = do
mkObs idx strm = do observer ("obs" P.++ show idx) strm
return (idx P.+ 1)
--- Example SAT function.
+
f0 :: SatFunc
-f0 = (3, \[a,b,c] -> a && (b || (not c)))
+--f0 = (3, \[a,b,c] -> a && (b || (not c)))
+f0 = (3, f)
+ where
+ f [a,b,c] = a && (b || (not c))
+ f _ = error "Bad SAT function."
f1 :: SatFunc
-f1 = (9, \[a,b,c,d,e,f,g,h,i] -> a && b && c && d && e &&
- f && g && h && i && i && not i)
+f1 = (9, f')
+ where
+ f' [a,b,c,d,e,f,g,h,i] =
+ a && b && c && d && e &&
+ f && g && h && i && i && not i
+ f' _ = error "Bad SAT function."
-- | Run the interpreter long enough to get an answer.
runFunc :: SatFunc -> IO ()
runFunc f = interpret (2 P.^ fst f) (satSpec f)
+satExamples :: IO ()
+satExamples = runFunc f0 >> runFunc f1
+
---------------------------------------------------------------------------------
View
8 Examples/Test.hs
@@ -25,11 +25,13 @@ import EngineExample
import Examples
import Examples2
import ExtFuns
+import Languages
import Local
import LTLExamples
import PTLTLExamples
import Random
import RegExpExamples
+import Sat
import StackExamples
import StatExamples
import VotingExamples
@@ -75,6 +77,9 @@ runTests = do
putStrLn "Testing extFuns ..."
extFuns >> cleanup
putStrLn ""
+ putStrLn "Testing language ..."
+ languages >> cleanup
+ putStrLn ""
putStrLn "Testing localEx ..."
localEx >> cleanup
putStrLn ""
@@ -90,6 +95,9 @@ runTests = do
putStrLn "Testing regExpExamples ..."
regExpExamples >> cleanup
putStrLn ""
+ putStrLn "Testing satExamples ..."
+ satExamples >> cleanup
+ putStrLn ""
putStrLn "Testing stackExamples ..."
stackExamples >> cleanup
putStrLn ""
Please sign in to comment.
Something went wrong with that request. Please try again.