diff --git a/README.md b/README.md index 869159b..7c9f4ef 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,19 @@ Try it out [here](https://garrepi.dev/swal) really just to explore SwiftWasm in a meaningful way. hopefully, someone finds directly interacting with the algorithms in [this swift library](https://github.com/apple/swift-algorithms) useful +### contributing + +feel free to contribute! I have a habit of starting projects and never finishing... + +the hosted version of this has to be updated manually by me (running it through my [static site](https://github.com/johngarrett/johngarrett.github.io)) + +also, `FileManager` and `String.write(to:,_:,_:)` seem to be broken in the wasm fork of swift. because of that, html is directly injected into the DOM. `StaticRenderer` is _suopssed_ to render all the HyperSwift into a html and css file but, without the ability to write, that's not being done. + ### status - [X] Combinations - [X] Permutations -- [ ] Rotations +- [X] Rotations - [ ] Partitions - [ ] Chain - [ ] Product diff --git a/swal2.html b/swal2.html deleted file mode 100644 index 0e2fbf8..0000000 --- a/swal2.html +++ /dev/null @@ -1,468 +0,0 @@ - - - - - - - - - -
-

Swift, WASM, and Algorithms

-
- - github - - - twitter - -
-
-
-
-

Combinations

-
-
- combinations(ofCount: ) -
-

A type that computes - combinations of a collection's elements.

This method returns a - sequence of all the different combinations of a collection's elements, with each combination in the order of - the original collection. -
-
-
-

array:

-
-
-

count:

-
-
-
-

-

-
-
-
-
-
-

Permutations

-
-
- permutations(ofCount: ) -
-

A type that computes - permutations of a collection's elements, or of a subset of those elements.

This method, when called - without the ofCount parameter, returns a sequence of all the different permutations of a collection's - elements -
-
-
-

array:

-
-
-

count:

-
-
-
-

-

-
-
-
-
-
-

Rotations

-
-
- rotations(toStartAt: )rotations(subrange: toStartAt: ) -
-

A mutating method that - rotates the elements of a collection to new positions.

To work around the CoW / - slice mutation problem for divide-and-conquer algorithms, which are the idiomatic use case for rotation, - this also includes variants that take a range -
-
-
-

source array:

-
-
-

rotate to:

-
-
-
-

-

-
-
-
-
-
-

Partition

-
-
- tablePartition(by:)partitioningIndex(where:) -
-

The standard library’s - existing partition(by:) method, which re-orders the elements in a collection into two - partitions based on a given predicate, doesn’t guarantee stability for either partition. That is, the order - of the elements in each partition doesn’t necessarily match their relative order in the original collection. - These new methods expand on the existing partition(by:) by providing stability for one or both - partitions.

The - partitioningIndex(where:) method returns the index of the start of the second partition when - called on an already partitioned collection. -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Chain

-
-
- chain(_:_:) -
-

Concatenates two collections - with the same element type, one after another.
This operation is available for any two sequences

- Unlike placing two - collections in an array and calling joined(), chaining permits different collection types, - performs no allocations, and can preserve the shared conformances of the two underlying types. -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Product

-
-
- product(_:_:) -
-

A function for iterating over - every pair of elements in two different collections.

When either collection is - empty, the resulting wrapper collection is also empty. -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Cycle

-
-
- cycled(times:) -
-

This combines two other - existing standard library functions (repeatElement and joined) to provide a more - expressive way of repeating a collection's elements a limited number of times.

-
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Random Sampling

-
-
- randomSample(count: )randomStableSample(count: )randomSample(count:, using: &) -
-

Operations for randomly - selecting k elements without replacement from a sequence or collection.

Use these methods for - sampling multiple elements from a collection, optionally maintaining the relative order of the elements. - Each method has an overload that takes a RandomNumberGenerator as a parameter. -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Unique

-
-
- uniqued()uniqued(on:)
-

Methods to strip repeated - elements from a sequence or collection.

The uniqued() - method returns an array, dropping duplicate elements from a sequence. The uniqued(on:) method - does the same, using the result of the given closure to determine the "uniqueness" of each element. -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Chunked

-
-
- chunked(by:)chunked(on:)
-

Break a collection into - subsequences where consecutive elements pass a binary predicate, or where all elements in each chunk project - to the same value.

chunked(by:) - uses a binary predicate to test consecutive elements, separating chunks where the predicate returns false. -
- chunk(on:), by contrast, takes a projection of each element and separates chunks where the - projection of two consecutive elements is not equal.
-
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
-
-
-

Indexed

-
-
- indexed()
-

The enumerated - method, but pairing each element with its index instead of an incrementing integer counter.

This is essentially - equivalent to zip(x.indices, x) -
-
-

This sandbox has not been implimented yet

-
- Check the progress here: github
-
-
-

-

-

-
-
-
- -