Socket
Socket
Sign inDemoInstall

algebra-cyclic

Package Overview
Dependencies
4
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    algebra-cyclic

creates a space isomorphic to Zp: the cyclic ring of order p, where p is prime


Version published
Weekly downloads
9
increased by12.5%
Maintainers
1
Install size
50.2 kB
Created
Weekly downloads
 

Readme

Source

algebra-cyclic

creates a space isomorphic to Zp: the cyclic ring of order p, where p is prime

Installation | API | Examples | License

NPM version Build Status JavaScript Style Guide

Uroboro{:.responsive}

Installation

With npm do

npm install algebra-cyclic

API

algebraCyclic(elements)

  • @param {Array|String} elements
  • @returns {Object} cyclic ring

algebraCyclic.error

An object exposing the following error messages:

  • numberOfElementsIsNotPrime
  • elementsAreNotUnique

Examples

All code in the examples below is intended to be contained into a single file.

var algebraCyclic = require('algebra-cyclic')

// Cyclic ring of vowels.
var vowel = algebraCyclic('aeiou')

vowel.contains('a') // true
vowel.contains('e') // true
vowel.contains('i') // true
vowel.contains('o') // true
vowel.contains('u') // true

vowel.contains('0') // false
vowel.contains('1') // false
vowel.contains('2') // false
vowel.contains('*') // false

vowel.addition('a', 'a') // 'a'
vowel.addition('a', 'e') // 'e'
vowel.addition('a', 'i') // 'i'
vowel.addition('a', 'o') // 'o'
vowel.addition('a', 'u') // 'u'
vowel.addition('e', 'e') // 'i'
vowel.addition('e', 'i') // 'o'
vowel.addition('e', 'o') // 'u'
vowel.addition('i', 'i') // 'u'
vowel.addition('i', 'o') // 'a'
vowel.addition('i', 'u') // 'e'
vowel.addition('o', 'o') // 'e'
vowel.addition('o', 'u') // 'i'
vowel.addition('u', 'u') // 'o'

vowel.subtraction('a', 'a') // 'a'
vowel.subtraction('a', 'e') // 'u'
vowel.subtraction('a', 'i') // 'o'
vowel.subtraction('a', 'o') // 'i'
vowel.subtraction('a', 'u') // 'e'
vowel.subtraction('e', 'e') // 'a'
vowel.subtraction('e', 'i') // 'u'
vowel.subtraction('e', 'o') // 'o'
vowel.subtraction('e', 'u') // 'i'
vowel.subtraction('i', 'i') // 'a'
vowel.subtraction('i', 'o') // 'u'
vowel.subtraction('i', 'u') // 'o'
vowel.subtraction('o', 'o') // 'a'
vowel.subtraction('o', 'u') // 'u'
vowel.subtraction('u', 'u') // 'a'

vowel.negation('a') // 'a'
vowel.negation('e') // 'u'
vowel.negation('i') // 'o'
vowel.negation('o') // 'i'
vowel.negation('u') // 'e'

// 'a' is considered as zero, and the following operation should throws
// cannotDivideByZero
vowel.inversion('a') // 'e'

vowel.inversion('e') // 'e'
vowel.inversion('i') // 'o'
vowel.inversion('o') // 'i'
vowel.inversion('u') // 'u'


// TODO complete operations (multiplication and divison)

The number of elements must be prime, and elements are required to be unique. The following snippets will throw.

// numberOfElementsIsNotPrime

algebraCyclic(['length', 'of', 'this', 'is', 'not', 'prime'])

// elementsAreNotUnique

algebraCyclic([1, 2, 1])

License

MIT

Keywords

FAQs

Last updated on 06 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc