Added examples

master
Abhinav Sarkar 2010-07-26 19:52:54 +05:30
parent b8da6992fe
commit 94d98e3402
3 changed files with 13 additions and 2 deletions

View File

@ -26,6 +26,8 @@
(defvar- attr-kw (keyword "@attr"))
(defvar- text-kw (keyword "#text"))
(defn- safe-parse-int [n]
(if (nil? n)
nil
@ -428,7 +430,7 @@
:mbid (-> data :artist :mbid))
:playcount (-> data :playcount safe-parse-int)
:listeners (-> data :listeners safe-parse-int)
:streamable (-> data :streamable :#text str-1?)
:streamable (-> data :streamable text-kw str-1?)
:streamable-full (-> data :streamable :fulltrack str-1?)))
(defvar- parse-artist-toptracks

View File

@ -0,0 +1,9 @@
(ns clj-lastfm.examples
(:use [clj-lastfm.core]))
(defn- indexed [s] (map vector (iterate inc 1) s))
(defn print-topten-tracks [artist-name]
(doseq [[idx name]
(->> artist-name artist-toptracks (take 10) (map :name) indexed)]
(println (format "%s. %s" idx name))))

View File

@ -1,6 +1,6 @@
# Based on the example properties given at http://logging.apache.org/log4j/1.2/manual.html
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=INFO,A1
log4j.rootLogger=ERROR,A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender