Skip to content

Commit c499011

Browse files
committed
Merge branch 'horizon'
2 parents fb93f9f + 1602fce commit c499011

File tree

7 files changed

+331
-180
lines changed

7 files changed

+331
-180
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ python:
44
branches:
55
only:
66
- horizon
7-
- sql
7+
- master
88
env:
99
global:
1010
- GH_REF: github.com/brownplt/pyret-docs.git
1111
- RACKET_DIR: ~/racket
1212
- RACKET_VERSION: '6.5'
13-
- secure: H5K8RszG02jJnvhZm+oQ+NFIyYte29mnk3soZ0Ya9Oq+ECxBU34C5WBJOBEyVldgQy6sKGWFxvXR2+6opZFUS1nzSy2e4t9Fvo0GxiCvJUWVyG9arfe2HNSCB93nOZYJNA3ApVfNOOt/tfKdaBAKSqbIznUBgn1Cr+PTLQtULaRV8cIf3SGC3493zhWyu6yO5zPvTpE6PijmnPPvLriOmLXNoSQ8jkULrhyVu8cORPCxM+3tCL3gIHK1kDfzSF19eSKuEfq/qOWvQcDLWDZsoBW8LrwljJyMIZVGWT2ns9Ig5aoND82qaie6KUjFPQOamLFPysaiT2Flp7tlz7cag+Cyi0oaZIcFEtc5YEl2BC1AGBBaNYT8OVprL9PQmptDL9cukkdUXOxjAazu8uixDZ0czA3FYVPOsE4Yr/86dz/oD1YLgSkj9sN6j8eJFdIBszUd0KNuDZWS+oiD0xbxcJVhZPOwujSUYn5Dkuo7u821V/oPQefpmZnG+w6SdU0t+yFIW3mZqWSYyH0uY2MiczXnu8bEaCFTTxj5x79ZWEPKFmmmrBG9FG3pd6SSGUvKL8ddbfFQagLseCeYAlSdUbij7zdnHgEg6aMYhccCtrJpwB9+b+Frj30KTB3aRyAVv1HboZboTVrHuWMQudDU+9Ws/xYpXzdOFvi0vOYDDAo=
13+
- secure: tkOgKmY5brk6wSTluhgKaFiUiVVXnf1HefE1v56LOUlNHcieMLjRAgXc5LsdezI5ymtf59tZBVAdv7zWG+2Co/nMgIVE20FLpT2UeZCyBu+669lDPZG5zJc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1G40YtUPXghMwxjYiDmwkM05fOnrUqwfobz98yrDm/6Q7KUEqUaUcV/RshLYcgXrOgSv9YSDykJ7BkvFhnDTOiHPVc4gg4GFHjZI0T8cCziyeroo3/pfR/Oe1kIXyuCzpP4kbY48JGE7GEvC7vT/dwOQ4ERt4XfzD2jlBaubqI6Boy95+VrKo=
1415
before_install:
1516
- git clone https://github.com/greghendershott/travis-racket.git
1617
- cat travis-racket/install-racket.sh | bash

deploy.sh

+13-38
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,21 @@
11
#!/bin/bash
22

3-
# Travis deploy script adapted from
4-
# http://lexi-lambda.github.io/blog/2015/07/18/automatically-deploying-a-frog-powered-blog-to-github-pages/
5-
6-
if [ -d "gh-pages" ]; then
7-
>&2 echo "Naming conflict. Either rename the folder 'gh-pages' or update the deploy script."
8-
fi
9-
10-
if [ "${TRAVIS_BRANCH}" -eq "master" ]; then
11-
export IS_DEVELOPMENT=false
12-
else
13-
export IS_DEVELOPMENT=true
14-
fi
15-
16-
BUILD_DIR=build/docs
17-
18-
set -ev # exit with nonzero exit code if anything fails
19-
20-
# Make sure there's no build directory already
21-
rm -rf $BUILD_DIR || exit 0;
22-
23-
# build blog
3+
SHORT_COMMIT=`echo $TRAVIS_COMMIT | cut -c1-7`
4+
VERSION=$SHORT_COMMIT
5+
BRANCH=$TRAVIS_BRANCH
246
npm install
257
make
268

27-
# Fetch gh-pages branch
28-
git clone --quiet -b gh-pages "https://${GH_TOKEN}@${GH_REF}" gh-pages > /dev/null 2>&1
29-
30-
# Remove any previous build and add the new one
31-
rm -rf "gh-pages/${TRAVIS_BRANCH}" || exit 0;
32-
mv $BUILD_DIR "gh-pages/${TRAVIS_BRANCH}"
33-
34-
# Commit the new build
35-
cd gh-pages
9+
tar czf build/docs.tgz build/docs
3610

37-
git config user.name "Travis CI"
38-
# Email here needs to be the same as the user who created
39-
# the Github access token for Travis
40-
git config user.email "[email protected]"
11+
# NOTE(joe):
12+
#
13+
# The "*" in front of dele makes the copy continue if the command fails. This
14+
# makes it so new branches don't need to have someone manually make a file to
15+
# delete (see the -Q option in `man curl`).
4116

42-
git add -A "${TRAVIS_BRANCH}"
43-
git commit -m "Deploy ${TRAVIS_BRANCH} build to Github Pages"
17+
curl -u $FTP_USER:$FTP_PASS \
18+
-Q "*dele pyret-docs/$BRANCH/docs.tgz"\
19+
--ftp-create-dirs \
20+
-T build/docs.tgz ftp://ftp.cs.brown.edu/pyret-docs/$BRANCH/docs.tgz
4421

45-
# Push the new build
46-
git push --quiet "https://${GH_TOKEN}@${GH_REF}" gh-pages > /dev/null 2>&1

src/libraries.scrbl

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This section contains information on libraries that come with Pyret.
1212
@include-section["builtin/strings.scrbl"]
1313
@include-section["builtin/booleans.scrbl"]
1414
@include-section["builtin/raw-arrays.scrbl"]
15+
@include-section["builtin/tables.scrbl"]
1516

1617
@include-section["trove/lists.scrbl"]
1718
@include-section["trove/sets.scrbl"]
@@ -31,7 +32,6 @@ This section contains information on libraries that come with Pyret.
3132
@include-section["trove/world.js.rkt"]
3233
@include-section["builtin/reactors.scrbl"]
3334
@include-section["trove/plot.js.rkt"]
34-
@include-section["builtin/tables.scrbl"]
3535
@include-section["trove/statistics.scrbl"]
36-
@;@include-section["trove/graph.js.rkt"]
36+
@include-section["trove/math.scrbl"]
3737

src/trove/lists.scrbl

+25-134
Original file line numberDiff line numberDiff line change
@@ -1783,140 +1783,7 @@ end
17831783

17841784
}
17851785

1786-
@function["max"
1787-
#:contract (a-arrow (L-of N) N)
1788-
#:args '(("lst" #f))
1789-
#:return N
1790-
]{
1791-
1792-
Given a list of numbers, returns the largest. Raises an error on empty lists.
1793-
1794-
@examples{
1795-
examples:
1796-
max([list: 1, 2, 3]) is 3
1797-
max([list: ]) raises "empty"
1798-
max([list: ~1, 3, 7/2]) is 7/2
1799-
end
1800-
}
1801-
1802-
}
1803-
1804-
@function["min"
1805-
#:contract (a-arrow (L-of N) N)
1806-
#:args '(("lst" #f))
1807-
#:return N
1808-
]{
1809-
1810-
Given a list of numbers, returns the smallest. Raises an error on empty lists.
1811-
1812-
@examples{
1813-
examples:
1814-
min([list: 1, 2, 3]) is 1
1815-
min([list: ]) raises "empty"
1816-
min([list: ~1, 3, -7/2]) is -7/2
1817-
end
1818-
}
1819-
1820-
}
1821-
1822-
1823-
@function["sum"
1824-
#:contract (a-arrow (L-of N) N)
1825-
#:args '(("lst" #f))
1826-
#:return N
1827-
]{
1828-
1829-
Given a list of numbers @pyret{x1, x2, ..., xn}, returns @pyret{x1 + x2 + ... + xn}.
1830-
1831-
@examples{
1832-
examples:
1833-
sum([list: 1, 2, 3]) is 6
1834-
sum([list: ]) is 0
1835-
sum([list: ~1, 3]) is-roughly ~4
1836-
end
1837-
}
1838-
}
1839-
1840-
@function["mean"
1841-
#:contract (a-arrow (L-of N) N)
1842-
#:args '(("lst" #f))
1843-
#:return N
1844-
]{
1845-
1846-
Given a list of numbers, returns their arithmetic mean. Raises an error on empty lists.
1847-
1848-
@examples{
1849-
examples:
1850-
mean([list: 1, 2, 6]) is 3
1851-
mean([list: ]) raises "empty"
1852-
mean([list: ~1, 3]) is-roughly ~2
1853-
end
1854-
}
1855-
1856-
}
1857-
1858-
@function["median"
1859-
#:contract (a-arrow (L-of N) N)
1860-
#:args '(("lst" #f))
1861-
#:return N
1862-
]{
1863-
1864-
Given a list of numbers, returns their median (taking the mean of the two
1865-
middle numbers if the list has even length). Raises an error on empty lists.
1866-
1867-
@examples{
1868-
examples:
1869-
median([list: 1, 2, 6]) is 2
1870-
median([list: ]) raises "empty"
1871-
median([list: ~1, 3]) is-roughly ~2
1872-
end
1873-
}
1874-
1875-
}
1876-
1877-
@function["stdev"
1878-
#:contract (a-arrow (L-of N) N)
1879-
#:args '(("lst" #f))
1880-
#:return N
1881-
]{
1882-
1883-
Given a list of numbers, returns their standard deviation. Raises an error
1884-
on empty lists.
1885-
1886-
@examples{
1887-
examples:
1888-
stdev([list: 3, 4, 5, 6, 7]) is%(within(0.01)) 1.41
1889-
stdev([list: 1, 1, 1, 1]) is-roughly ~0
1890-
stdev([list:]) raises "empty"
1891-
end
1892-
}
1893-
1894-
}
1895-
1896-
@function["distinct"
1897-
#:contract (a-arrow (L-of N) N)
1898-
#:args '(("lst" #f))
1899-
#:return N
1900-
]{
1901-
1902-
Given a list, returns a new list containing only one copy of each element
1903-
that is duplicated in the list. The last (latest in the list) copy is kept.
1904-
Roughnums are not compared for equality, and so will always appear in the
1905-
output list.
1906-
1907-
@examples{
1908-
examples:
1909-
distinct([list: 3, 1, 2, 2, 3, 2]) is [list: 1, 3, 2]
1910-
distinct([list: ~1, ~1]) is-roughly [list: ~1, ~1]
1911-
distinct([list: ~1, ~1, 1]) is-roughly [list: ~1, ~1, 1]
1912-
distinct([list: ~1, ~1, 1, 1]) is-roughly [list: ~1, ~1, 1]
1913-
distinct([list: ~1, ~2, ~3]) is-roughly [list: ~1, ~2, ~3]
1914-
end
1915-
}
1916-
1917-
}
1918-
1919-
1786+
19201787
@function[
19211788
"get"
19221789
#:examples
@@ -2014,6 +1881,30 @@ end
20141881
end
20151882
}
20161883
]
1884+
@function["distinct"
1885+
#:contract (a-arrow (L-of N) N)
1886+
#:args '(("lst" #f))
1887+
#:return N
1888+
]{
1889+
1890+
Given a list, returns a new list containing only one copy of each element
1891+
that is duplicated in the list. The last (latest in the list) copy is kept.
1892+
Roughnums are not compared for equality, and so will always appear in the
1893+
output list.
1894+
1895+
@examples{
1896+
examples:
1897+
distinct([list: 3, 1, 2, 2, 3, 2]) is [list: 1, 3, 2]
1898+
distinct([list: ~1, ~1]) is-roughly [list: ~1, ~1]
1899+
distinct([list: ~1, ~1, 1]) is-roughly [list: ~1, ~1, 1]
1900+
distinct([list: ~1, ~1, 1, 1]) is-roughly [list: ~1, ~1, 1]
1901+
distinct([list: ~1, ~2, ~3]) is-roughly [list: ~1, ~2, ~3]
1902+
end
1903+
}
1904+
1905+
}
1906+
1907+
20171908
@function[
20181909
"filter"
20191910
#:examples

src/trove/math.scrbl

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#lang scribble/manual
2+
@(require "../../scribble-api.rkt" "../abbrevs.rkt")
3+
@(require (only-in scribble/core delayed-block))
4+
5+
@(define (link T) (a-id T (xref "statistics" T)))
6+
@(define (t-field name ty) (a-field (tt name) ty))
7+
8+
@(define (t-record . rest)
9+
(apply a-record (map tt (filter (lambda (x) (not (string=? x "\n"))) rest))))
10+
11+
@(append-gen-docs
12+
`(module "math"
13+
(path "src/arr/trove/math.arr")
14+
15+
(fun-spec (name "sum") (arity 1))
16+
(fun-spec (name "max") (arity 1))
17+
(fun-spec (name "min") (arity 1))
18+
(fun-spec (name "arg-min") (arity 1))
19+
(fun-spec (name "arg-max") (arity 1))
20+
))
21+
22+
@docmodule["math"]{
23+
The Pyret Math library. It consists of functions for arithmetic
24+
calculations, optimization, and more to come!
25+
26+
Every function in this library is available on the @tt{math} module
27+
object. For example, if you used @pyret{import math as M}, you would
28+
write @pyret{S.arg-max} to access @pyret{arg-max} below. If you used
29+
@pyret{include}, then you can refer to identifiers without writing @pyret{M.}
30+
as a prefix.
31+
32+
@;#########################################################################
33+
@section{Arithmetic Functions}
34+
@function["sum"
35+
#:contract (a-arrow (L-of N) N)
36+
#:args '(("l" #f))
37+
#:return N
38+
]{
39+
Calculates the arithmetic sum of the Numbers in @pyret{l}. If @pyret{l}
40+
contains at least one RoughNum, then the output will be a RoughNum.
41+
42+
@examples{
43+
sum([list: 0, 2, 4])
44+
sum([list: -1, 1, ~2])
45+
}
46+
}
47+
48+
@;#########################################################################
49+
@section{Minimization & Maximization}
50+
51+
@function["max"
52+
#:contract (a-arrow (L-of N) N)
53+
#:args '(("l" #f))
54+
#:return N
55+
]{
56+
Calculates the maximal element of the set of Numbers in @pyret{l}.
57+
58+
@examples{
59+
max([list: 2.1, 2, 4.5, ~1.5, -1, 1])
60+
}
61+
}
62+
63+
@function["min"
64+
#:contract (a-arrow (L-of N) N)
65+
#:args '(("l" #f))
66+
#:return N
67+
]{
68+
Calculates the minimal element of the set of Numbers in @pyret{l}.
69+
70+
@examples{
71+
min([list: -1, 0, ~1, 2, 5])
72+
}
73+
}
74+
75+
@function["arg-max"
76+
#:contract (a-arrow (L-of N) N)
77+
#:args '(("l" #f))
78+
#:return N
79+
]{
80+
Calculates the index of the maximal element within @pyret{l}.
81+
82+
@examples{
83+
arg-max([list: -1, 0, ~1, 2, 5])
84+
}
85+
}
86+
@function["arg-min"
87+
#:contract (a-arrow (L-of N) N)
88+
#:args '(("l" #f))
89+
#:return N
90+
]{
91+
Calculates the index of the minimal element within @pyret{l}.
92+
93+
@examples{
94+
arg-max([list: -1, 0, ~1, 2, 5])
95+
}
96+
}
97+
}

src/trove/plot.js.rkt

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
Every function in this library is available on the @tt{plot} module object.
4444
For example, if you used @pyret{import plot as P}, you would write
4545
@pyret{P.display-function} to access @pyret{display-function} below. If you used
46-
@pyret{include}, then you can refer to identifiers without needing to prefix
47-
with @pyret{P.}.
46+
@pyret{include}, then you can refer to identifiers without needing to prefix
47+
with @pyret{P.}
4848

4949
@;############################################################################
5050
@section{The Plot Type}

0 commit comments

Comments
 (0)