# Numbers

Numbers are stored as integers or ratios (numerator and denominator) when possible, using an internal BigNumber library. This allows it to perserve fractions when possible.

*rand*: random numbers.

`()->[0,1], (max)->[0,max], (min,max)->[min,max]`

*sin*,

*cos*,

*tan*: the usual trig functions, in radians or degrees.

*add*,

*mul*, etc. function implementations of the standard math operations.

*as*, converts number to specified unit.

*pow*, power. 5^2 = pow(5,2)

*exp*, e^n

*sqrt*, square root

*max*,

*min*, max and min of the arguments. Works with scalars and lists and lambda to pull out sub-part to compare

*random_integer(max)*: returns a random number between 0 and the max

*randomreal*or

*randomfloat*?

*is_prime*return true if number is prime

*sign*sign of the argument. returns -1, 0, or 1

# Lists

*range*: generate a list of numbers:

`(max), (min,max), (min,max,step)`

*map*: convert every element in a list using a lambda function:

`(list, lam)`

*for*: loops over every element in a list with a lambda, but returns the original list:

`(list, lam)`

*sort*: sort list returning a new list, by: property to use for sorting

`sort(data by:"date")`

(should we use `order`

instead?)
*take*: take the first N elements from a list to make a new list

`take([1,2,3], 2) = [1,2]`

*drop*: return list with the number of elements removed from the start.

`drop([1,2,3],1) = [2,3]`

*pick*: take random elements from list

`pick(data,5)`

get five random elements
*reverse*: return a list with the order reversed

`reverse(data)`

*select*: select items from list using where: lambda function returning false.

`select(data, where=(t)=>t.amount>0)`

*join*: concatenate two lists, returning a new list.

*length*: returns the length of the list

*sum*: adds all data points together

# charts

*plot*: lot a list of numbers as a scatter plot. x is the index in the list. y is the value of each number. can also plot equations as lambdas.

**__type__: `point | line | number`**point: draw each datum as a point

**line: draw lines connecting all of the points**number: draw points on a number line

*chart*:

*type*: bar, pie, stacked?

*histogram*: draws a histogram of the data

# Strings

Unlike in the Wolfram language, you don't need separate functions for strings. They will act as lists of characters so `take`

, `length`

, `join`

, etc will work just fine.

*string*, make a string literal. same as doing

`"some words here"`

. Maybe it should be *text*instead?

*length*: works on strings too

*to_upper_case*,

*to_lower_case*,

*capitalize*transform between cases. returns new strings.

*characters*: splits into a list of single char strings

# Graphics

Standard 2D graphics using the PDF / Canvas / SVG imaging model. Lengths and points may be specified with
units, like `rect(width=2cm, height=1ft)`

. If no units are supplied then it is assumed to be pixels.

*point*: a two component vector

`point(25,50) === [25,50]`

*draw*: draws lists/nested lists of shapes. optionally set size of the canvas area

*circle*: a circle shape with center, radius, and fill

*rect*: a rect shape with width, height, position and fill

`rect(width=100, height=50)`

*regular_polygon*: an N-gon. ex: regular_polygon(5) = pentagon. accepts fill and center position.

*pack_row*: packs shapes in a row, centered vertically

*pack_col*: packs shapes in a column, centered horizontally. works on shapes, scalars and other elements.

*pack_grid*: packs shapes in grid of the specified size.

*draw_geomap*: draws a geo map

*address_to_geo*: converts a street address to a geo coordinate (US addresses only)

*color*: make a color. accept strings, hex RGB triplets, and keywords for red,green,blue, hue,saturation,value, or hue, saturation, lightness. supports abbreviations too. and all CSS named strings. Maybe split into RGB and HSV color functions?

*line_path*: a polyline, may or may not be closed. may or may not be filled. only lines (no curves). specify a list of xy pairs as points.

*curve_path*: a path made of bezier curves

# Images

*CameraImage*: takes an image from the camera, if available.

*Image*: get an image from a url

# Dates and Time

For the most part dates and time are just scalars with units. You can create a datetime, do simple arithmetic with it, and convert between timezones. There are three types: Dates, Times, and DateTimes.

*Now*: DateTime representing right now.

*Today*,

*Tomorrow*,

*Yesterday*: dates representing these days.

*Date*: create a new date from a string. optionally specify a format

*Time*: create a new time from a string. optionally specify a format.

*DateTime*: create a new date-time from a string. optionally specify a format.

Maybe

# sound

Deferring for now.

# Tables or lists of lists or multi-dimensional arrays

I need to do more work on this. Follow APL's lead here about shape and rank. examples:

# GeoData

Calculate geographical locations and draw maps. The basics are easy but this requires more thought about how this would actually be used, and where the map data comes from. Could we actually do something like show the 30 nearest volcanos?

# Constants

# data access

**US states w/ dates, flags, abbreviations, capital cities, etc. lat/lon center, border,**Countries of the world including: english name, local name, population, ISO code, primary language, flags, etc.

**planets and moons in the solar system including: mass, radius, orbital period, rotational period, albedo, photos, and more.**cities: major US cities

**buildings: tallest buildings in the world**

# Questionable

*IntegerDigits*: split number into list of single digits.

`IntegerDigits(4200)`

= `[4,2,0,0]`

*count*: number of times element appears in the list.

`count(list,'foo')`

. Is this useful?
*first*,

*last*: return the first or last elements of the list. can't we use

`take(data,n)`

.
*rest*return the list minus the first element

*part*: wolfram uses part for array element selection. is this easier than

`data[n]`

indexing?
*ColorNegate*wolfram uses this to find a complientary color, but I think it's only using the hue.

*Blend*mixes colors. Couldn't we do it with math?

*RandomColor*vs making colors with random values in the constructor

*Style*to style the output with colors and font sizes. Not clear what the 'output' is in these cases, since it could be anything. Really it's styling the output panel in the interface. I'm unsure about this.

`Disc`

vs `Circle`

.
*TextWords*returns list the english words in the string. ignores punctuation.

*TextSentences*returns list of sentences in the string.

**maybe useful?**