File tree 3 files changed +43
-13
lines changed
3 files changed +43
-13
lines changed Original file line number Diff line number Diff line change @@ -1293,11 +1293,20 @@ processMState' (MState mode env loops bindings ((MAtom pattern target matcher):t
1293
1293
_ ->
1294
1294
case matcher of
1295
1295
UserMatcher _ _ _ -> do
1296
- (patterns, targetss, matchers) <- inductiveMatch env' pattern target matcher
1297
- mfor targetss $ \ ref -> do
1298
- targets <- evalRef ref >>= fromTupleWHNF
1299
- let trees' = zipWith3 MAtom patterns targets matchers ++ trees
1300
- return $ MState mode env loops bindings trees'
1296
+ case pattern of
1297
+ _ -> do
1298
+ (patterns, targetss, matchers) <- inductiveMatch env' pattern target matcher
1299
+ case (length patterns, length matchers) of
1300
+ (1 ,1 ) -> do
1301
+ mfor targetss $ \ ref -> do
1302
+ targets <- evalRef ref >>= (\ x -> return [x])
1303
+ let trees' = zipWith3 MAtom patterns targets matchers ++ trees
1304
+ return $ MState mode env loops bindings trees'
1305
+ _ -> do
1306
+ mfor targetss $ \ ref -> do
1307
+ targets <- evalRef ref >>= fromTupleWHNF
1308
+ let trees' = zipWith3 MAtom patterns targets matchers ++ trees
1309
+ return $ MState mode env loops bindings trees'
1301
1310
1302
1311
Tuple matchers ->
1303
1312
case pattern of
Original file line number Diff line number Diff line change 55
55
<nil>)>
56
56
a])))
57
57
58
+ (test (n-queen 4))
59
+ (test (n-queen 5))
60
+ (test (n-queen 6))
61
+ (test (n-queen 7))
58
62
(test (n-queen 8))
59
63
(test (n-queen 9))
60
64
(test (n-queen 10))
Original file line number Diff line number Diff line change 1
- (define $common-seqs
2
- (lambda [$xs $ys]
3
- (match-all [xs ys] [(list char) (list char)]
4
- [[(loop $i [1 $n] <join _ <cons $c_i ...>> _)
5
- (loop $i [1 n] <join _ <cons ,c_i ...>> _)]
6
- (map (lambda [$i] c_i) (between 1 n))])))
1
+ (define $double-list
2
+ (lambda [$a]
3
+ (matcher
4
+ {
5
+ [<cons $ $> [[a a] (double-list a)]
6
+ {[[$xs $ys] (match-all [xs ys] [(list a) (list a)]
7
+ [[<cons $x $rs1> <cons $y $rs2>]
8
+ [[x y] [rs1 rs2]]])]}]
9
+ [<join $ $> [[(list a) (list a)] (double-list a)]
10
+ {[[$xs $ys] (match-all [xs ys] [(list a) (list a)]
11
+ [[<join $hs1 $ts1> <join $hs2 $ts2>]
12
+ [[hs1 hs2] [ts1 ts2]]])]}]
13
+ [<c-cons $ $> [a (double-list a)]
14
+ {[[$xs $ys] (match-all [xs ys] [(list a) (list a)]
15
+ [[<cons $x $rs1> <cons ,x $rs2>]
16
+ [x [rs1 rs2]]])]}]
17
+ [$ something
18
+ {[$tgt {tgt}]}]
19
+ })))
7
20
8
- (define $lcs (compose common-seqs rac))
21
+ (define $lcs
22
+ (lambda [$xs $ys]
23
+ (match-all [(unpack "thisisatest") (unpack "testing123testing")] (double-list char)
24
+ [(loop $i [1 $n] <join _ <c-cons $c_i ...>> _)
25
+ [n (pack (map (lambda [$i] c_i) (between 1 n)))]])))
9
26
10
- (test (lcs "thisisatest" "testing123testing"))
27
+ (sort/fn 2#(compare (2#%1 %1) (2#%1 %2)) (lcs "thisisatest" "testing123testing"))
You can’t perform that action at this time.
0 commit comments