This project contains realisations of common-used math functions and classical algorithms, written in Scala's pure-functional style.
Some of them are a new sight at Scala's standard library, some are persistent data structures, some are completely new functions.
The main purpose of this library is to spread ideas of a functional programming in Scala and to challenge yourself by creating classical imperative algorithms in a new way.
Would be great, if you contribute, in case that presented algorithms are not as effective as they can be, and you know how to fix this, or if you have ideas, that can be added in the future.
-
Quick sort
sortingAlgorithms/QuickSort
-
Bubble sort
sortingAlgorithms/BubbleSort
-
Merge sort
sortingAlgorithms/MergeSort
-
Insertion sort
sortingAlgorithms/InsertionSort
-
Selection sort
sortingAlgorithms.SelectionSort
-
Heap sort
sortingAlgorithms.HeapSort
-
LinkedList
dataStructures.LinkedList
-
Queue
dataStructures.Queue
-
Stack
dataStructures.Stack
-
Binary tree
dataStructures.BinaryTree
-
Heap
dataStructures.Heap
-
Red-Black Tree
dataStructures.RedBlackTree
-
Polymorphic lambda calculus
lambdaCalculus/PolymorphicLambdaCalculus
-
Pure Lambda Calculus PureLambdaCalculus.scala
lambdaCalculus/PureLambdaCalculus
integerOperations.IntegerProperties
-
.isOdd
-
.isEven
-
.isSquared
-
.sumOfDigits
-
.compositionOfDigits
-
.numOfDigits
-
.divisors
-
.nthGreatestDivisor(n)
-
.numOfDivisors
-
.sumOfDivisors
-
.isPrime, works with O(sqrt(n)) speed
-
.isPrimeFermat(). works with O(log(n)) speed
-
.sqr
-
.powN()
-
.gcdWith(secondInt)
-
.isPrimeFermatStrict (does not fail on Carmichael numbers, works slowly)
-
.isPrimeFermatFast (does not fail on Carmichael numbers, works fast, only with Ints)
-
.lcmWith(secondInt)
-
Factorial (!)
-
Double factorial (!!)
-
Convolution of a number (127 -> 1+2+7 -> 10 -> 1+0 -> 1)
-
.isFreeOfSquares
-
.isCarmichael
-
.isLuc_Carmichael
-
.isFibonacci
-
.nthCatalan
-
.binaryPower(), works with O(log(n)) speed
-
.isZuckerman
-
.isHarshad
-
.gcdExtendedWith()
integerOperations.IntegerGenerators
-
Arithmetic regression
-
Arithmetic progression
-
Squares until N
-
Divisors of N
-
Binary divisors of N
-
Divisors, multiple by N
-
Prime divisors
-
Carmichael numbers
-
Luc-Carmichael numbers
-
Fibonacci numbers
-
Random ints
-
Catalan numbers
integerOperations.IntegerGeneratorsMath
-
Fermat numbers
-
Eratosthenes primes sieve O(log(log(n)))
-
.isVowel
-
.isConsonant
doubleOperations.DoubleProperties
-
.inverse
-
.sqrDouble
-
.abs
-
.toDegrees
-
.incDouble
-
get(List[A], index)
-
isPalindrome(List[A])
-
isPalindrome([A])
-
Counter for the number of sign changes in a list of integers
-
Counter for the number of letter changes from vowel to consonant in a list of integers
-
.isSorted
-
binary search in a list
-
linear search in a list
-
permutations(List[A], len)
-
permutationsCount
-
accomodations
-
combinations
-
accomodations with repeats
-
combinations with repeats
-
Rational numbers
additionalArithmetics.Rational
-
Complex numbers
complexOperations.Complex
-
.bypassOnComplete()
-
.ifFailure()
-
.result
-
.completeAndThen()
-
.completeAndThenComplete()
-
.getOrZero
-
.getOrZeroL
-
.getOrThrow
-
.getOrEmpty
-
.getOrMax
-
Pi
-
Tau
-
E
-
Pythagoras constant
-
Theodorus constant
-
Gamma
-
Phi
-
Plastic number
- Conversions of hours, seconds and minutes.
- Operations with double
-
Martin Odersky's "Functional Programming in Scala Specialization "https://www.coursera.org/specializations/scala" (English)
-
Chris Okasaki's "Purely Functional Data Structures" (English)
-
Richard Bird's "Pearls of Functional Algorithm Design" (English)
-
Denis Shevchenko's "About Haskell in a human way": https://www.ohaskell.guide (Russian)
-
Louis Botterill's mostly software and techy Blog: http://louisbotterill.blogspot.ru (English)
-
Alvin Alexander's scala blog: https://alvinalexander.com (English)
-
Richard G.E. Pinch "The Carmichael numbers up to 10^18" https://arxiv.org/pdf/math/0604376v1.pdf (English)
-
Site about algorithms http://e-maxx.ru (Russian/English)
-
"Rosetta code" website about algorithms: https://rosettacode.org/wiki/Rosetta_Code (English)
-
Vladimir Kostykov's Scala algorithms library: https://github.com/vkostyukov/scalacaster (English)
-
Raul Rojas's "A Tutorial Introduction to the Lambda Calculus": http://www.inf.fu-berlin.de/lehre/WS03/alpi/lambda.pdf (English)
-
ITMO University's wiki: https://neerc.ifmo.ru/wiki/index.php?title=Лямбда-исчисление (Russian)