Code Monkey home page Code Monkey logo

utils's Introduction

Utils

Generic utilities.

  • utils:random-string number

Usage and installation

(ql:quickload "utils")

API

List utilities

  • (pg-reverse lst) function: Reverse the elements of the list. (Thanks Mr. Paul Graham)
CL-USER> (pg-reverse '(1 2 3 4))
(4 3 2 1)
  • (list+ lst number) function: Adding number in a all elements of the lst (lst is a list of numbers).
CL-USER> (list+ '(1 2 3 4) 5)
(6 7 8 9)
  • (combine-cars lst1 lst2) function: Combine the elements of the list, first with first, second with second ... return a list of list.
CL-USER> (combine-cars '(1 2 3) '(4 5 6))
((1 4) (2 5) (3 6))
  • (mklist atom) function: Transform an atom in a list
CL-USER> (mklist 'abc)
(abc)
  • (firsts lst) function: lst is a list of lists. Extract the cars of the sublists.
CL-USER> (first '((1 2 3) (4 5 6) (7 8 9)))
(1 4 7)
  • (my-member atom lst) function: Check if atom exist in lst.
CL-USER> (my-member 'abc '(1 3 4 abc add))
T
CL-USER> (my-member 'abc '(1 3 4 abcd add))
NIL
  • (rfember atom lst) function: Remove the first coincidence of atom in the lst.
CL-USER> (rfember 'abc '(foo bar baz abc buu abc 1 2))
(FOO BAR BAZ BUU ABC 1 2)
  • (rember atom lst) function: Remove all coincidences of atom in the lst.
CL-USER> (rember 'abc '(foo bar baz abc buu abc 1 2))
(FOO BAR BAZ BUU 1 2)
  • (replace-atom new-atom old-atom lst) function: Replace the first coincidence of old-atom to new-atom
CL-USER> (replace-atom 'new 'old '(abc def 1 old 2 3 5 old))
(ABC DEF 1 NEW 2 3 5 OLD)
  • (full-replace-atom new old lst) function: Replace all the coincidences of the old atom for the new atom in the list.
CL-USER> (full-replace-atom 'new 'old '(abc def 1 old 2 3 5 old))
(ABC DEF 1 NEW 2 3 5 NEW)

Filesystem utilities

  • (directory-p pathname) function: Return true if pathname is a directory
CL-USER> (directory-p "/home/")
T
CL-USER> (directory-p "/home/lisper/sound.ogg")
NIL
  • (file-exists-p pathname) function: Return true if the file exist (directories and files)
CL-USER> (file-exists-p "/home")
T
CL-USER> (file-exists-p "/homeds")
NIL

Random String

  • (random-string length) function: Return a random string of length
CL-USER> (random-string 20)
"f6RL/AqHrZ3Q]y7nXUhT"

Author

Copyright

Copyright (c) 2019 Innaky ([email protected])

License

Licensed under the GPLv3 License.

utils's People

Contributors

innaky avatar

Watchers

 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.