Mired in code
Check-in [8635150a25]
Not logged in
Public Repositories
mwm's Repositories

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a test case and run it
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8635150a2514b7ef5d4b30d6083bdd4f2f2616f7
User & Date: mwm@mired.org 2010-08-19 21:24:24
Context
2010-08-23
01:19
Add the enscript state file for clojure check-in: e12e0b1991 user: mwm@mired.org tags: trunk
2010-08-19
21:24
Add a test case and run it check-in: 8635150a25 user: mwm@mired.org tags: trunk
2010-02-23
00:39
Add the phrase-groups example. check-in: 9670fdf1da user: mwm@mired.org tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to clojure/phrase-groups.clj.



1
2
3
4
5
6
7
..
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
34
35
36
37
38
39
40









(defn mfilter
  "Return a hash-map built by removing entries for which (pred (key entry))
  returns false from mapin."
  [pred mapin]
  (apply hash-map (apply concat (filter #(pred %) mapin))))

(defn enumerate
................................................................................
    (update-in phrase-dict [phrase list-index] conj phrase-index)
    phrase-dict))
  
(defn add-list-to-phrase-dict [phrase-dict list-index list]
  (reduce (fn [phrase-dict [phrase-index phrase]]
	    (add-phrase-to-phrase-dict phrase-dict phrase list-index phrase-index))
	  phrase-dict
	  (enumerate (map vector list (rest list) (rest (rest list))))))

(defn build-phrase-dict [lists]
  (let [phrase-dict (reduce (fn [phrase-dict [list-index list]]
			      (add-list-to-phrase-dict phrase-dict 
						       list-index list))
			    {}
			    (enumerate lists))
................................................................................
	   (apply sorted-map (mapcat vector (iterate inc 0) list))))

(defn remove-shared-phrases [lists]
  (let [phrases (apply merge-with concat (vals (build-phrase-dict lists)))]
    (doseq [[idx list] (enumerate lists)]
      (println (vals (remove-phrases-from-list (phrases idx) list))))))








>
>







 







|







 







>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
..
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env clj

(defn mfilter
  "Return a hash-map built by removing entries for which (pred (key entry))
  returns false from mapin."
  [pred mapin]
  (apply hash-map (apply concat (filter #(pred %) mapin))))

(defn enumerate
................................................................................
    (update-in phrase-dict [phrase list-index] conj phrase-index)
    phrase-dict))
  
(defn add-list-to-phrase-dict [phrase-dict list-index list]
  (reduce (fn [phrase-dict [phrase-index phrase]]
	    (add-phrase-to-phrase-dict phrase-dict phrase list-index phrase-index))
	  phrase-dict
	  (enumerate (map vector list (rest list) (nthnext list 2)))))

(defn build-phrase-dict [lists]
  (let [phrase-dict (reduce (fn [phrase-dict [list-index list]]
			      (add-list-to-phrase-dict phrase-dict 
						       list-index list))
			    {}
			    (enumerate lists))
................................................................................
	   (apply sorted-map (mapcat vector (iterate inc 0) list))))

(defn remove-shared-phrases [lists]
  (let [phrases (apply merge-with concat (vals (build-phrase-dict lists)))]
    (doseq [[idx list] (enumerate lists)]
      (println (vals (remove-phrases-from-list (phrases idx) list))))))


(def mp [["As" "input" "we" "get" "the" "phrase" "dictionary" "we're" "going"]
	 ["to" "update" "the" "phrase" "dictionary" "input" "list" "in" "the"]
	 ["list" "of" "lists" "and" "the" "phrase" "dictionary" "Wanting" "to"]])


(remove-shared-phrases mp)

Added zfs/zfsbootfrom.sh.











>
>
>
>
>
1
2
3
4
5
#!/bin/sh
FS=$1
POOL=$(echo $FS | sed 's;/.*;;')
$DEBUG zfs set bootfs=$FS $POOL
$DEBUG sed -i .old "/vfs.root.mountfrom/s;=.*;=\"zfs:$FS\"" /boot/loader.conf