Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lists

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lists - npm Package Compare versions

Comparing version 0.1.96 to 0.1.97

2

package.json
{
"name": "lists",
"version": "0.1.96",
"version": "0.1.97",
"description": "A library of higher-order functions modeled after Haskell's Data.List module",

@@ -5,0 +5,0 @@ "main": "lists.js",

@@ -11,9 +11,49 @@ # [ l [ i [ s ] t ] s ]

-----
## Install
-----
## Components
## Practical Example Usage
-----
Lets complete an easy task from [/r/dailyprogrammer](http://www.reddit.com/dailyprogrammer). [Here](http://www.reddit.com/r/dailyprogrammer/comments/29i9jw/6302014_challenge_169_easy_90_degree_2d_array/) is the task:
**Given a NxN size 2D array of numbers. Develop a way to rotate the data as if you rotated the data by 90 degrees clockwise.**
The challenge input is a 10x10 matrix that looks like this:
```js
var matrix =
[[1,2,3,4,5,6,7,8,9,0],
[0,9,8,7,6,5,4,3,2,1],
[1,3,5,7,9,2,4,6,8,0],
[0,8,6,4,2,9,7,5,3,1],
[0,1,2,3,4,5,4,3,2,1],
[9,8,7,6,5,6,7,8,9,0],
[1,1,1,1,1,1,1,1,1,1],
[2,2,2,2,2,2,2,2,2,2],
[9,8,7,6,7,8,9,8,7,6],
[0,0,0,0,0,0,0,0,0,0]];
```
Using **lists**, we can reverse and then transpose this matrix to achieve the desired output:
```js
l.transpose(l.rev(matrix));
// or using pipe (composing left)
var rotate90 = lists.pipe(lists.transpose, lists.rev)
rotate90(matrix);
/* both of these functions yield
[[0,9,2,1,9,0,0,1,0,1],
[0,8,2,1,8,1,8,3,9,2],
[0,7,2,1,7,2,6,5,8,3],
[0,6,2,1,6,3,4,7,7,4],
[0,7,2,1,5,4,2,9,6,5],
[0,8,2,1,6,5,9,2,5,6],
[0,9,2,1,7,4,7,4,4,7],
[0,8,2,1,8,3,5,6,3,8],
[0,7,2,1,9,2,3,8,2,9],
[0,6,2,1,0,1,1,0,1,0]];
/*
```
## Type Signature Legend

@@ -20,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc