Skip to content

yayoc/intersperse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intersperse intersperse :: a -> [a] -> [a]

takes an element or a function and a list and intersperse that element between the elements of the list.

Example

const intersperse = require("@yayoc/intersperse"); 

intersperse("," "ABCDEF") // "A,B,C,D,E,F"

intersperse("/", [1,2,3]) // [1, "/", 2, "/", 3]

intersperse({ a: "A" }, [1,2,3]) // [1, { a: "A" }, 2, { a: "A" }, 3]

intersperse("/", []) // []

intersperse((prev, next) => {
  return prev + next;   
}, [1,2,3]) // [1, 3, 2, 5, 3]

intersperse((prev, next) => {
  return prev + next;   
}, ["a","b","c"]) // ["a", "ab", "b", "bc", "c"]

About

intersperse in JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published