Commit 8fe76c90 authored by Alf Kristian Støyle's avatar Alf Kristian Støyle

Removed uneccessary requires for clojure.string and better naming as to string

not str (bad habit).
parent 45031b66
......@@ -3,12 +3,12 @@
(:import (java.util.regex Pattern))
[clojure-workshop-flatmap.args :as args]
[clojure.string :as str]))
[clojure.string :as string]))
(defn split-retain-empty-lines
"Splits a line into a seq, where empty lines are retaines as an empty string \"\""
(str/split text #"\r?\n"))
(string/split text #"\r?\n"))
(defn format-line
"Formats lines with prefixed numbering"
......@@ -49,7 +49,7 @@
for each file over cat. Then converts each result vector to only the text (the second part of cat
result). Finally joins these with a \newline (check out clojure.string functions)."
[opts files]
(str/join \newline
(string/join \newline
(map second
(map (partial cat opts)
(map read-file files)))))
......@@ -68,7 +68,7 @@
; What is the next count?
cnt (+ current-cnt (count lines))]
[(assoc state :line-cnt cnt)
(str/join \newline formatted-lines)]))
(string/join \newline formatted-lines)]))
(defn number-non-blank-lines
"Takes state (potentially containg a current :line-count) and text and formats it using format
......@@ -86,7 +86,7 @@
[n (conj xs "")]))
[current-cnt []] lines)]
[(assoc state :line-cnt cnt)
(str/join \newline formatted-lines)]))
(string/join \newline formatted-lines)]))
(defn cat-in
"Loops over system/in until ctrl-d is pressed converting input to cat for each new line"
(:use midje.sweet
(:require [clojure.string :as str]))
(fact "read-file should actually read file contets"
......@@ -49,4 +48,4 @@
" 2 to")]
(number-non-blank-lines {:line-cnt 2} "en\n\nto") => [{:line-cnt 4} (str " 2 en\n"
" 3 to")])
\ No newline at end of file
" 3 to")])
(ns clojure-workshop-flatmap.ex-2
(:use [midje.sweet])
(:require [clojure.string :as str]))
(:use [midje.sweet]))
(def _ 0)
(defn __ [& args] false)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment