First off, I'd recommend adding a search function as a site feature instead of directly as a URL, then the entry line can escape the search term and the search page can subsequently unescape it from the URL arguments. This way you don't have to worry about special characters in URLs.
Second, I read your post, thought about it, and suddenly there was this whole system. Have a gander.
Data types: Scalar values and rectangular multidimensional arrays of scalar values.
Scalar literals: Simply a string of digits, possibly prefixed by a minus sign.
Examples: 1 3 4 6 8 145 -5 3 2
Lists: Just a collection of scalar literals, separated by commas and enclosed by braces. Empty lists are not allowed.
Examples: {3} {5,6,8} {45} {-3,5}
Multidimensional lists are a comma-separated brace-enclosed list of other lists, all of which must have exactly the same dimensions. Jagged arrays are not allowed.
Examples: {{0}} {{1},{2}} {{1,3,4},{4,6,1}}
Illegal examples: {{1},{2,3}}, {1,{2}}
Operators don't use precedence, but are executed left-to-right (it makes sense, trust me). You can use parentheses (()) to override this left-to-right behavior.
Here's a list of operators:
AxN AtN
List repetition. Takes a list or scalar on the left side, and a scalar on the right. Creates a flat (or non-flat when using t) list of N copies of A.
Examples:3x4 => {3,3,3,3}
{4,8}x2 => {4,8,4,8}
{4,8}t2 => {{4,8},{4,8}}
4t3t2 => {{4,4,4},{4,4,4}}
AdB
Dice roll. Takes any combination of lists and scalars, operates recursively component-wise if given two lists. Dice without a positive number of sides all roll 0.
Examples:1d6 => 3
{1,1,1,1}d6 => {2,6,2,5}
4x1d6 => {1,4,5,3} // same thing as above
1d{4,6,8,10,12,20,100} => 4,3,2,10,9,18,40
A*B A/B A%B
Multiplication, integer division, modulus. Takes any combination of lists and scalars, operates recursively component-wise if given two lists.
Examples:3*4 => 12
{7,8,9}%3 => {3,0,1}
12/{2,3,5} => {6,4,2}
{1,10,100}*{2,3,4,5} => {2,30,400} // Note that the final list length is the shorter of both lengths.
{{1,2,3},{4,5,6}}*{3,4} => {{3,6,9},{16,20,24}} // Note the recursion.
A+B A-B
Addition and subtraction. Works like dice rolls or multiplication, but adds or subtracts.
Examples:4-3 => 1
{1,2}+{3,4} => {4,6}
L_B L.B
Subscript operator. Takes a list on the left, and a scalar or list on the right (indices are 1-based to comply with the dice mechanic). The underscore operates on the outermost list, the dot on the innermost.
Examples:{0,3,5,1}_2 => 3 // Indexing by a scalar decreases the list dimension.
{10,20,30,40}_{2,4,3} => {20,40,30} // Indexing by a list doesn't.
{{1,2,3},{4,5,6}}_1 => {1,2,3}
{{1,2,3},{4,5,6}}.1 => {1,4}
{{1,2,3},{4,5,6}}_{2,1} => {{1,2,3},{4,5,6}}
{{1,2,3},{4,5,6}}.{2,1} => {{2,1},{5,4}}
LkN
Value drop. Takes a list on the left and a scalar on the right. Either drops the N lowest (or -N highest if N is negative) values from every innermost lists.
Examples:{3,1,4,1,2,2}k3 => {2,3,4}
{{4,4,0},{2,-3,1}}k1 => {{4,4},{1,2}}
LsN LpN
Partial sums, partial products. Replaces every innermost list M with a list of every possible sum (s) or product (p) using N values from M. Special case: s0 or p0 works like s|M| or p|M|, but returns scalars instead of one-element lists. Sorts the result.
Examples:{1,2,3}p2 => {2,3,6}
{2,7,3,6}s2 => {5,8,9,9,10,13} // Note that there are two ways to get 9. Both nines are kept to keep the array rectangular.
{3,5,1,3,9,2,4}s1 => {1,2,3,3,4,5,9} // This just sorts the list.
{3,5,1,3,9,2,4}s7 => {27} // A one-element list containing the sum of the previous list.
{3,5,1,3,9,2,4}s7_1 => 27 // How to get at the single element.
{3,5,1,3,9,2,4}s0 => 27 // Shortcut to do the same thing as above.
LiN
Transposition. Takes a multidimensional list on the left and a scalar on the right. Transposes the 1st and Nth indices (indices are counted from the inside).
Examples:{{1,2,3},{4,5,6}i2 => {{1,4},{2,5},{3,6}}
{{{1,2},{3,4}},{{5,6},{7,8}}}i2 => {{{1,3},{2,4},{5,7},{6,8}}}
{{{1,2},{3,4}},{{5,6},{7,8}}}i2i3i2 => {{{1,2},{5,6}},{{3,4},{7,8}}}
Advanced example:1x4t6d6k1s0s1 => A set of six DnD stats, generated by "roll 4d6, choose 3", sorted for convenience.