Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dahan committed Jun 8, 2016
1 parent 11f4c1f commit f3f3228
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Algorithm.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'Algorithm'
s.version = '1.0.7'
s.license = 'BSD'
s.version = '1.0.8'
s.license = 'BSD-3-Clause'
s.summary = 'A toolset for writing algorithms in Swift.'
s.homepage = 'http://cosmicmind.io'
s.social_media_url = 'https://www.facebook.com/graphkit'
Expand Down
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
![CosmicMind](http://www.cosmicmind.io/CM/CosmicMind.png)
![CosmicMind](http://www.cosmicmind.io/algorithm/index/images/AlgorithmIcon.png)

## Welcome to Algorithm

Explore a world of data structures in Swift. Learn how to use data structures to organize, analyze, and manipulate data.
Algorithm is a collection of data structures that are empowered by a probability toolset.

Algorithm's architecture is designed for beginners and professionals. Its robust API requires no setup and is ready for the simplest and most extensive applications.

## Requirements

* iOS 8.0+ / Mac OS X 10.9+
* Xcode 7.2+
* Xcode 7.3+

## Communication

Expand All @@ -31,6 +33,7 @@ Algorithm is a growing project and will encounter changes throughout its develop
## A Tour

* [Probability](#probability)
* [ExpectedValue](#expectedvalue)
* [DoublyLinkedList](#doublylinkedlist)
* [Stack](#stack)
* [Queue](#queue)
Expand All @@ -44,23 +47,20 @@ Algorithm is a growing project and will encounter changes throughout its develop
<a name="probability"></a>
## Probability

Probability is a core feature. Your application may be completely catered to your users' habits and usage. To demonstrate this wonderful feature, let's look at some examples:
Each data structure within Algorithm is equipped with probability tools.

#### Basic Probability

Determining the probability of rolling a 3 using a die of 6 numbers.
For example, determining the probability of rolling a 3 using a die of 6 numbers.

```swift
let die: Array<Int> = Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
print(die.probabilityOf(3)) // Output: 0.166666666666667
```

The expected value of rolling a 3 or 6 with 100 trials using a die of 6 numbers.

```swift
let die: Array<Int> = Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
print(die.expectedValueOf(100, elements: 3, 6)) // Output: 33.3333333333333
```
#### Conditional Probability

The above examples are quite simple. They use basic calculations to determine the probability of an outcome (X). What if you have a complicated condition? To solve this problem, it is possible to pass in blocks that return a boolean value. Each block may execute any operations it pleases, so long as it returns a "true" or "false". The "true" values contribute to the likelihood of an outcome, "false" results do not. Below is an example to demonstrate this feature.
For conditional probabilities that require a more complex calculation, use block statements.

```swift
let die: Array<Int> = Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
Expand All @@ -78,6 +78,16 @@ if 0.33 < probabilityOfX {
}
```

<a name="expectedvalue"></a>
## Expected Value

The expected value of rolling a 3 or 6 with 100 trials using a die of 6 numbers.

```swift
let die: Array<Int> = Array<Int>(arrayLiteral: 1, 2, 3, 4, 5, 6)
print(die.expectedValueOf(100, elements: 3, 6)) // Output: 33.3333333333333
```

<a name="doublylinkedlist"></a>
## DoublyLinkedList

Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.7</string>
<string>1.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit f3f3228

Please sign in to comment.