今天玩了下clojure, 试着解析xml。
有几点心得:
1> 确实简练:
(ns work (:require
[clojure.xml :as xml]
[clojure.zip :as zip]
[clojure.data.zip.xml :as zf] )
)
(defn parse-xml-file
"parse xml to zipper map"
[xml-file]
(zip/xml-zip (xml/parse xml-file))
)
(defn get-value [xml & tags]
(apply zf/xml->
xml
(conj (vec tags) zf/text))
)
(def xml-var (parse-xml-file "test.xml"))
;to get 'a/b'
(get-value xml-var :a :b)
2> 如果a是根节点那么检索不到。这是为什么?待解答。
3> apply 的用法,要在详细研究。
4> vec 与vector 是不同的函数
(vec '(1 2 3));return [1 2 3]
(vector '(1 2 3));return [(1 2 3)]
这一点,要仔细研究。
分享到:
相关推荐
Parse the difference between functional and object-oriented programming Understand Clojure performance and capabilities Develop reactive web pages using ClojureScript Adopt an REPL-driven development ...
这是Programming Clojure 电子版的 纸质版本在美国亚马逊要到2009年3月才能上架 Paperback: 200 pages Publisher: Pragmatic Bookshelf (March 15, 2009) Language: English ISBN-10: 1934356336 ISBN-13: 978-...
Clojure is an opinionated language—it doesn’t try to cover all paradigms or provide every checklist bullet-point feature. Instead it provides the features needed to solve all kinds of real-world ...
Practical Clojure Clojure语言书籍
clojure clojure clojureclojure clojure
【1】[Clojure编程乐趣](The Joy of Clojure).pdf 【2】Clojure – Functional Programming for the JVM中文版.pdf 【3】Clojure Cookbook.pdf 【4】Clojure Data Analysis Cookbook.pdf 【5】clojure Hand book...
[2013] Functional Programming Patterns in Scala and Clojure - Write Lean Programs for the JVM.(Michael Bevilacqua-Linn).[1937785475].pdf+epub.rar [2014] Clojure Cookbook - Recipes for Functional ...
Typed Clojure 保留了 Clojure 的优势,是 Clojure 的可选类型系统,也可以说是 Clojure 的一个库,改善了大量的静态类型安全检测。主要特性:从 Java 中保护你的 Clojure 程序,进行安全的互操作,正确的使用外部 ...
Clojure编程乐趣和clojure_programming.pdf两本书
[2009] Programming Clojure.(Stuart Halloway).[1934356336].pdf [2010] Functional Programming with Clojure - Simple Concurrency on the JVM.(Tim Berglund, Matthew McCullough).[193650202X].pdf [2010] ...
Learn to handle data using sequences, reducers, and transducers in Clojure Explore the lesser known and more advanced features, constructs, and methodologies of the Clojure language and its ecosystem,...
Clojure入门教程- Clojure – Functional Programming for the JVM中文版
[奥莱理] Clojure 编程 (英文版) [奥莱理] Clojure Programming (E-Book) ☆ 出版信息:☆ [作者信息] Chas Emerick, Brian Carper, Christophe Grand [出版机构] 奥莱理 [出版日期] 2012年04月19日 [图书页数...
clojure1.3.0及资料,附《Programming Clojure》,《Practical Clojure》
Clojure是一个JVM的动态函数式语言,最近发布了1.0版本,版本中Clojure提供了一个健壮的代码。Clojure是一套发展快速的新的编程语言,特别是,它为多核计算做了新的解决方案。在今后的软件设计中无论使用Clojure语言...
Clojure Data Analysis Cookbook
The Joy of Clojure, Second Edition is a deep look at the Clojure language. Fully updated for Clojure 1.6, this new edition goes beyond just syntax to show you the "why" of Clojure and how to write ...
【1】Web Development with Clojure(2014.1).pdf 【2】clojure_programming.pdf 【3】Practical Clojure.pdf 【4】Programming Clojure with Emacs.pdf 【5】Programming Concurrency on the JVM(Java虚拟机并发编程...
Clojure入门教程