锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲电影唐人社一区二区,亚洲视频一区二区在线观看,精品日韩亚洲AV无码一区二区三区 http://m.tkk7.com/chaocai/category/52793.htmlzh-cnMon, 26 Nov 2012 07:17:44 GMTMon, 26 Nov 2012 07:17:44 GMT60The Clojure Program To solve N Queens Problem (Without back tracing)http://m.tkk7.com/chaocai/archive/2012/11/26/Clojure.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Mon, 26 Nov 2012 04:21:00 GMThttp://m.tkk7.com/chaocai/archive/2012/11/26/Clojure.htmlhttp://m.tkk7.com/chaocai/comments/391968.htmlhttp://m.tkk7.com/chaocai/archive/2012/11/26/Clojure.html#Feedback0http://m.tkk7.com/chaocai/comments/commentRss/391968.htmlhttp://m.tkk7.com/chaocai/services/trackbacks/391968.htmlThe following solution not using the back tracing way is more concise and readable, but for the searching space becomes huger, the performance is much worser then the previous one.

(ns SICP.unit3)
(defn conflictInCol? [s col]
  (some #(= col %) s)
)

(defn conflictInDia? [s col]
  (let [dia (count s)
        n1 (fn [c
] (Math/abs (- dia (.indexOf s c))))
        n2 (fn [c] (Math/abs (- col c)))]
    (some #(= (n1 %) (n2 %)) s)
  )
)

(defn safe? [s col] 
  (not (or (conflictInCol? s col) (conflictInDia? s col)))
)
  
(defn next-level-queens [solutions-for-prev-level board-size current-level]
  (let [solutions (atom [])]
    (doseq [s solutions-for-prev-level]
      (doseq [col (range 0 board-size)]
        (if (safe? s col)
          (reset! solutions (cons (conj s col) @solutions))
     
        )
       )
   
    )
   
      (if (< current-level (dec board-size))
        (recur @solutions board-size (inc current-level))
        (count @solutions)
      )
   )
)

(defn queens [board-size]
  (next-level-queens  (apply vector (map #(vector %) (range 0 board-size))) board-size 1)
)

Chao Cai (钄¤秴錛?br />Sr. SDE
Amazon


 

]]>
Clojure XPathhttp://m.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Mon, 15 Oct 2012 02:15:00 GMThttp://m.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.htmlhttp://m.tkk7.com/chaocai/comments/389555.htmlhttp://m.tkk7.com/chaocai/archive/2012/10/15/ClojureXPath.html#Feedback0http://m.tkk7.com/chaocai/comments/commentRss/389555.htmlhttp://m.tkk7.com/chaocai/services/trackbacks/389555.html
The functions to support using XPath in Clojure.

Source Code

 1 ;The code was implemented by caichao@amazon.com
 2 ;You could use the code anyway, but should keep the comments
 3 ;Created 2012.10
 4 (ns clojure.ccsoft.xml
 5   (:require [clojure.xml :as xml]))
 6  
 7 (import '(java.io StringReader)
 8         '(java.io ByteArrayInputStream))
 9  
10 (defn xml-structure [xml-txt] 
11    [ (xml/parse (-> xml-txt
12               (.getBytes)
13               (ByteArrayInputStream.)
14      )
15     )]
16 )
17  
18 (defn node [tag xmlStruct]
19  
20   (first (filter #(= (:tag %) tag) (:content xmlStruct)))
21 )
22  
23 (defn node [path xml-txt]
24    (loop [path path 
25           xml-content (xml-structure xml-txt) 
26           ]
27       (let [current-tag (first path) current-elem (first xml-content)]
28         (if (= (:tag current-elem ) current-tag)
29  
30           (if (= (count path) 1)
31             current-elem 
32             (recur  (rest path) (:content current-elem ))
33           )
34           (if (> (count  xml-content) 1)
35            (recur path  (rest xml-content))
36           )
37         )
38      )
39     )
40  )

How to Use

(def cmd-example "<command>
                   <header>
                     
<type>script</type>
                     
<transaction_id>12345</transaction_id>
                   
</header>
                   
<body>
                      println 
3+4;
                   
</body>
                  
</command>")
 
 
(node [:command :header :transaction_id] cmd
-example)




]]>
主站蜘蛛池模板: 欧亚精品一区三区免费| 国产精品一区二区三区免费| 无码人妻久久一区二区三区免费| 久久精品国产亚洲Aⅴ香蕉| 美女视频黄.免费网址| 免费a级毛片18以上观看精品| 亚洲Aⅴ在线无码播放毛片一线天 亚洲avav天堂av在线网毛片 | 妞干网免费视频观看| 亚洲色精品VR一区区三区| 在线观看视频免费国语| 亚洲人成色77777在线观看| 国产成人涩涩涩视频在线观看免费| 日本亚洲中午字幕乱码| 亚洲电影日韩精品| 成人av片无码免费天天看| 亚洲av无码专区国产乱码在线观看| 日本免费久久久久久久网站| 亚洲国产理论片在线播放| 免费精品一区二区三区在线观看| 国产亚洲精品美女| 亚洲理论电影在线观看| 最近免费视频中文字幕大全| 亚洲性色AV日韩在线观看| 免费国产a国产片高清| 中文精品人人永久免费| 亚洲自偷精品视频自拍| 蜜桃精品免费久久久久影院 | 在线免费播放一级毛片| 亚洲欧洲自拍拍偷综合| 暖暖在线日本免费中文| 国产无遮挡色视频免费观看性色| 久久久无码精品亚洲日韩蜜桃| 无码少妇一区二区浪潮免费| 污网站免费在线观看| 亚洲人成亚洲精品| 免费鲁丝片一级在线观看| 国产黄色片免费看| 亚洲一区二区三区四区视频| 四虎影库久免费视频| 免费国产污网站在线观看15| 亚洲av无码无线在线观看|