GithubHelp home page GithubHelp logo

clj-left-pad's Introduction

clj-left-pad

Circle CI

Clojars Project

A Clojure library for left-padding strings, with a function signature that lends itself better to functional style programming.

Usage

In your project.clj:

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [clj-left-pad "1.0.0"]])

And in the file you want to use clj-left-pad:

(ns your-beautiful-thing.core
  (:require [clj-left-pad.core :refer [left-pad]))
(left-pad 5 "foo")
;=> "  foo"

(left-pad "x" 5 "foo")
;=> "xxfoo"

Motivation

There are, at this time of writing (2018-02-11), three libraries for left-padding strings on clojars, and all of them have the same function signature:

(left-pad :stringToPad :length :paddingCharacter)

They all otherwise do the same, some utilizing other libraries for string formatting and such. I got a bit annoyed, having to monkey-patch an imported library to have the signature I wanted

(defn proper-left-pad
  ([len s] (left-pad s len))
  ([ch len s] (left-pad s len ch)))

So I wrote my own. No, I hope you do not seriously need to ever use this little library.

License

Copyright © 2018, Victor Nascimento Bakke.

Released under the MIT License.

clj-left-pad's People

Contributors

gipphe avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.