BEE Manual v.1.62
by Ruben Abagyan and Eugene Raush
Copyright © 2004, Molsoft LLC
Jul 28 2004

Contents
 
Intruduction
Quickref
Language Reference
Built-in Functions
Regular expressions
System variables
Modules
 
Index

[ Intruduction | Quickref | Language Reference | Built-in Functions | Regular expressions | System variables | Modules ]

Info> string 's' (8725 bytes) is loaded
Table of contents

1 Intruduction

[Top]


2 Quick Reference Guide

[Top]

[ Main types ]

2.1 Main data types

[Top]

[ integer | real | logical | string | integer-array | real-array | larray | sarray | matrix | collection ]

integer ( i )

Integer constants can be written in decimal of hex form:


a = 0x10
print a,2,-12,1+2

real ( r )

Real constants can be written in decimal or exponetial form:


a = 1.2;
print a,1.5e-5;
real.format variable contains the default output style for the real values.

logical ( l ) e.g. yes,no,0110L

string ( s ) has the following forms:

  • "string", (double-quoted C-style) interprets special symbols: \a,\b,\n,\t,\\,\",\decimal
  • 'string', (single-quoted Pascal-style) no interpretation by bee. Single quote inside the string should be doubled. E.g: 'John''s pen'
  • multiline: e.g.
    
        s += <<END
         formatted text as is
         insert BEE $variable using dollar
        END
        

Integer array (I)

Integer arrays can be created from 'constant form' or using iarray() constructor. Random () function can be used to create a random integer array.


a = {2,-2,1}
b = iarray()       # create an empty integer array
c = iarray(10)     # create an integer array of 10 zero elements
d = Random(1,5,10) # create random integer array of 10 elements from [1:5] range

Real array (I)

Reals arrays can be created from 'constant form' or using rarray() constructor. Random () function can be used to create a random real array.


a = {2.2,3.e-12}
b = rarray()       # create an empty real array
c = Random(0.,1.,100 )

larray ( L ) {yes,no,yes} {01L,11L}

Larray can contain multibit elements with names. For example:


ll={011L,100L}; ll.names={"isSmart","isFast","isNice"}
show ll.isSmart

sarray ( S )

matrix ( M )

Matrix has no constant repsentation. M=matrix(3,3,4.2)

collection ( c )

Collections can contain named elements of any type, nested arrays and collections. Elements can accessed by name or by posistion. ( see index expressions )


a = {a=1,b=2}		    # create a collection
a[1]					      # take element by position
a["a"]					    # or a.a (take element by name)
a.c = 10				    # create new named element "c"
a //= "some string" # append new unnamed element
# create more complex collection
a = { a ={1 2 3}, 
      b = {a=1,b="fff"}, 
      c = matrix(5) 
    }
a.a[1]			# take first element of iarray
a.b.b       # returns "fff"

* table, T, - e.g. T={1 2 3}///{"a","b","c"}* folder, F, - bee-shell folder created by the mkdir command e.g. -- mkdir News; cd News -- * preference, p, - a fixed choice. The type itself has a choice e.g. -- color=preference('red','green','blue',2); c=color[1] -- * link, k, - links to an object, e.g. -- b="asdf"; a=link(b) -- a and b point to the same string. * selection in a set, y, - is returned by the Match function and selection ( set [ ~~ index expressions ~~ ] ). E.g. a=Match("bab",'[^b]'), b=selection(a[{2,5,7:9}]

* function, f, - e.g. -- function f(x) return x*x; endfunction -- * file, U, - a disk file. E.g.


 f=file("doc.txt"); f.Write("aaa",append"); file("a").Read('\0')>> Split>> Nof
* date, d, - e.g. -- date.format="%YY.%MM"; date(); date("2000.12") -- <>


3 Language Reference

[Top]

[ Flow control | Index expressions | User functions | User classes | Operations ]

3.1 Flow control

[Top]

3.2 Index expressions and named access

[Top]

Elements of sets (collectively A ) such as: arrays, collection"s, and tables, as well as parts of a string and a multibit logical can be accessed with several index expressions:

  • a single element: A[ i ], use A[ $ ] and A[ -n ] for access to the last element and n-th element from the end, respectively.
  • an element by name for collections, tables and logical arrays with named bits: A[ elementName ] , or A . elementName , e.g. c={a=1,b="ss"} ; c.a; c["a"]
  • A range: A[ i:j ]
  • A subset selected by iarray, logical mask, logical array, string array or a logical function: A[{ I | l | L | f }]. Examples for A = {1 2 3 4 5 6}


 A [{1,3:5}]; A[{1,3,5}]    # by iarray
 A [010101L]                # by logical mask
 A [{yes,no,yes,no,no,yes}] # by larray
 A > 3                      # elements larger than 3
 A [Sqrt > 2]               # by function
 A [function (x) x**2 > 5]  # by in-line function

Nested access is allowed for complex sets containing other sets:
A[exprLevel1 , exprLevel2]
An example:
{"asdf","1234","zxcv"}[2:3,2] # extracts { "2","x" }

3.3 User functions

[Top]

3.4 User classes

[Top]

3.5 Operations

[Top]


4 Built-in Functions

[Top]

[ Abs | Acos | Acosh | Angle | Asin | Asinh | Ask | Atan | Atan2 | Atanh | Augment | Axis | Beta | BetaInc | BetaLn | Boltzmann | Ceil | CloseConsole | Comp | Complement | Corr | Cos | Cosh | Count | Crypt | DateAdd | DateDiff | DatePart | Decrypt | Det | Disgeo | Distance | Eigen | Erfc | Eval | ExecSql | Existenv | Exp | Extension | Field | Find | Floor | Gamma | GammaInc | GammaLn | Gauss | Getenv | Group | Help | Histogram | ID2Object | Index | Indexx | Insert | Integral | Join | Length | LinearFit | Log | Match | Max | Mean | Median | Min | Minimize | Mod | Money | Name | Nof | Object2ID | Ord | Path | Percentile | Pi | Power | Putenv | Quantile | RaiseError | Random | ReactionRead | Regexp | Remainder | ReopenTable | Replace | Rmsd | Rot | Score | SendMail | Serialize | Sign | Sin | Sinh | Size | Smooth | Sort | Split | Sprintf | Sqrt | Square | Sum | Tan | Tanh | Tensor | TestRead | Time | Tolower | Toupper | Trace | Trans | Transform | Transpose | Trim | Type | Unique | Unix | Unserialize | Vector | Version | Volume ]

4.1 Abs

[Top]

Absolute value function

Examples:


a = Abs( -1 )
a = Abs( { 1, -2, -5 } )

4.2 Acos

[Top]

Acos( r )

Acos( R )

4.3 Acosh

[Top]

Acosh( r )

Acosh( R )

4.4 Angle

[Top]

Angle( v1=R v2=R )

Angle( p1=R p2=R p3=R )

4.5 Asin

[Top]

Asin( r )

Asin( R )

4.6 Asinh

[Top]

Asinh( r )

Asinh( R )

4.7 Ask

[Top]

Options: [only=no]

Ask( s )

Ask( s default={i|r|l} )

Ask( s answers=S [default=''] )

Ask( s default=s [simple] )

Ask( s )

Ask( s default={i|r|l} )

Ask( s answers=S [default=''] )

Ask( s default=s [simple] )

4.8 Atan

[Top]

Atan( r )

Atan( R )

4.9 Atan2

[Top]

Atan2( x=r y=r )

Atan2( x=R y=R )

4.10 Atanh

[Top]

Atanh( r )

Atanh( R )

4.11 Augment

[Top]

Augment( transformation=R )

Augment( cell=R )

Augment( xyz=R )

Augment( xyz=M )

4.12 Axis

[Top]

Axis( transformation=R )

Axis( rotation=M )

4.13 Beta

[Top]

Beta( a=r b=r )

4.14 BetaInc

[Top]

BetaInc( a=r b=r x=r )

4.15 BetaLn

[Top]

BetaLn( a=r b=r )

4.16 Boltzmann

[Top]

4.17 Ceil

[Top]

Ceil( r )

Ceil( r base=r )

Ceil( R )

Ceil( R base=r )

4.18 CloseConsole

[Top]

4.19 Comp

[Top]

Comp( A B [compare=f] )

4.20 Complement

[Top]

Complement( I to=i [from=1] )

4.21 Corr

[Top]

Corr( R R )

Corr( R R w=R )

4.22 Cos

[Top]

Cos( r )

Cos( R )

4.23 Cosh

[Top]

Cosh( r )

Cosh( R )

4.24 Count

[Top]

Count( groupBy [keyName='Key'] [dataName='Count'] )

Count( to=i )

Count( from=i to=i )

4.25 Crypt

[Top]

Crypt( s [simple] )

Crypt( s key=s [simple] )

4.26 DateAdd

[Top]

DateAdd( date=d increment=i part=p )

Redefinition:

date.options.part

4.27 DateDiff

[Top]

DateDiff( from=d to=d part=p )

Redefinition:

date.options.part

4.28 DatePart

[Top]

DatePart( date=d part=p )

Redefinition:

date.options.part

4.29 Decrypt

[Top]

Decrypt( s key=s [simple] )

4.30 Det

[Top]

Det( M )

4.31 Disgeo

[Top]

Disgeo( M )

4.32 Distance

[Top]

Distance( v=L )

Distance( v1=I v2=I )

Distance( v1=R v2=R )

Distance( xyz=M )

Distance( xyz1=M xyz2=M )

Distance( v1={L|l} v2={L|l} )

4.33 Eigen

[Top]

4.34 Erfc

[Top]

Erfc( r [] )

Erfc( R [] )

4.35 Eval

[Top]

4.36 ExecSql

[Top]

function to send a SQL query to the database server.

ExecSql( query=s [runInThread=no] [db=D] )

ExecSql( query=s function=f [db=D] )

Examples:


s = "jack"
ExecSql( "select * from mytable where name=$s" )  # substitutes bee shell variable

4.37 Existenv

[Top]

Existenv( env=s )

4.38 Exp

[Top]

Exp( r )

Exp( R )

Exp( M )

4.39 Extension

[Top]

Extension( s [dot] )

Extension( S [dot] )

4.40 Field

[Top]

Options: [delimiter="\s+"]

Field( s field={i|I} [delimiter=''] )

Field( S field={i|I} [delimiter=''] )

Field( str=s start=s field={i|I} [delimiter=''] )

Field( str=S start=s field={i|I} [delimiter=''] )

4.41 Find

[Top]

Options: [local=no]

Find( T s )

Find( s find=s [field=0] [offset=1] )

Find( s find=s field=I [offset=1] )

Find( fromTable=B toTable=s )

Find( fromTable=B toTable=s fields=s )

Find( fromTable=B toTable=s fields=s relationName=s )

4.42 Floor

[Top]

Floor( r )

Floor( r base=r )

Floor( R )

Floor( R base=r )

4.43 Gamma

[Top]

Gamma( a=r )

4.44 GammaInc

[Top]

GammaInc( a=r x=r )

4.45 GammaLn

[Top]

GammaLn( a=r )

4.46 Gauss

[Top]

Gauss( n=i )

4.47 Getenv

[Top]

Getenv( env=s )

4.48 Group

[Top]

function to group by a non-unique table field and apply a function to derive a summary of another fields from each unique sub-group.

For example, calculate partial sums of column income according to a key-column family to generate the income-per-family table. returns the tableof unique key values and grouped target columns.

Group( T groupBy [targetColumns] [funcs] [targetNames=S] )

Arguments:

  • T - table to which the Group function is applied.
  • groupBy - the name of the column determining the groups
  • targetColumns - sarray of column names to apply grouping operations
  • funcs - arrayof grouping functions to apply
  • targetNames - sarray of new names for grouping columns
Avaible grouping functoins are: Min, Max, Mean, Sum, Count

Examples:


show tt
#>-Names----Debit------Credit----
"John"   100.000000 10.000000 
"Sam"    200.000000 10.000000 
"Tom"    50.000000  10.000000 
"John"   500.000000 20.000000 
"Sam"    132.000000 20.000000 
"John"   12.000000  20.000000 
#
# Apply listed functions to 'Debit' and 'Credit' columns
#
Group(tt {"Names"} {"Debit","Debit"} {Sum, Mean})

#>-Names----A----------B----------C---------
"John"   612.000000 204.000000 50.000000 
"Sam"    332.000000 166.000000 30.000000 
"Tom"    50.000000  50.000000  10.000000 

4.49 Help

[Top]

4.50 Histogram

[Top]

Histogram( I )

Histogram( R nCells=i )

Histogram( R cellSize=r )

Histogram( R from=r to=r cellSize=r )

Histogram( R cellRuler=R )

4.51 ID2Object

[Top]

ID2Object( id=s )

4.52 Index

[Top]

Index( array value [] )

Index( s substring )

Index( s substring regexp )

Index( S substring regexp )

4.53 Indexx

[Top]

Indexx( s find=s [len] )

4.54 Insert

[Top]

Insert( list value [name=''] [pos=0] )

Insert( T col [name=''] [pos=0] )

4.55 Integral

[Top]

Integral( R x=r )

Integral( y=R x=R )

4.56 Join

[Top]

Join( col col [inner] [columns] )

4.57 Length

[Top]

4.58 LinearFit

[Top]

LinearFit( x=R y=R )

LinearFit( x=R y=R w=R )

4.59 Log

[Top]

Log( r )

Log( r base=r )

Log( R )

Log( R base=r )

Log( R base=i )

Log( M )

Log( M base=r )

4.60 Match

[Top]

function to find regular expressions in a text or string.

Options: [global=no,all=no]

Match( s find=s [field=0] [offset=1] )

Match( S find=s [field=0] [offset=1] )

Match( s find=s field=I [offset=1] )

Match( S find=s field=I [offset=1] )

4.61 Max

[Top]

Max( array )

Max( M )

Max( groupColumn dataColumn [groupName='Key'] [dataName='Max'] )

Max( i i )

Max( r r )

Max( array={I|R} max=r )

4.62 Mean

[Top]

Mean( x group [names=S] )

Mean( R )

Mean( R w=R )

Mean( I )

Mean( M )

Mean( M [all] )

4.63 Median

[Top]

Median( {R|I} )

4.64 Min

[Top]

Min( array )

Min( M )

Min( groupColumn dataColumn [groupName='Key'] [dataName='Min'] )

Min( i i )

Min( r r )

Min( array={I|R} min=r )

4.65 Minimize

[Top]

Options: [method=.auto,mncalls=100,tolgrad=0.000000,printIterations=no]

Minimize( function=f [n=1] [start=R] )

Minimize( function=f gradient=f [n=1] [start=R] )

4.66 Mod

[Top]

Mod( i )

Mod( i divider=i )

Mod( r )

Mod( r divider=r )

Mod( I )

Mod( I divider=i )

Mod( R )

Mod( R divider=r )

4.67 Money

[Top]

Money( r [format='$%.m'] )

4.68 Name

[Top]

Name( collection field=i )

4.69 Nof

[Top]

Nof( object [element] )

4.70 Object2ID

[Top]

Object2ID( object )

4.71 Ord

[Top]

4.72 Path

[Top]

Path( s )

4.73 Percentile

[Top]

Percentile( {R|I} percent=r )

4.74 Pi

[Top]

4.75 Power

[Top]

Power( I )

Power( base exp )

4.76 Putenv

[Top]

Putenv( env=s )

Putenv( name=s value )

4.77 Quantile

[Top]

Quantile( {R|I} position=i )

4.78 RaiseError

[Top]

RaiseError( message=s )

4.79 Random

[Top]

Random( i )

Random( s )

Random( from=i to=i )

Random( from=r to=r )

Random( s n=i )

Random( from=r to=r n=i )

Random( from=i to=i n=i )

Random( from=r to=r nRows=i nColumns=i )

Random( nRows=i nColumns=i from=r to=r )

Random( from=i to=i nRows=i nColumns=i )

4.80 ReactionRead

[Top]

ReactionRead( filename=s )

4.81 Regexp

[Top]

Regexp( string=s [flags=''] )

4.82 Remainder

[Top]

Remainder( i [divider=i] )

Remainder( r [divider=r] )

Remainder( I [divider=i] )

Remainder( R [divider=r] )

4.83 ReopenTable

[Top]

ReopenTable( table=B )

4.84 Replace

[Top]

function to find regular expressions in a text or string and replace them by another string.

Options: [global=yes,exact=no]

Replace( s find=s replace=s [field=0] [offset=1] [returnField=0] )

Replace( s find=s replace=f [field=0] [offset=1] [returnField=0] )

Replace( s find=s replace=f field=I [offset=1] [returnField=0] )

Replace( S find=s replace=s [field=0] [offset=1] [returnField=0] )

Replace( s find=S replace=S [field=0] [offset=1] [returnField=0] )

The replacement string can contain:

  • an explicit string
  • a back-reference to a sub-match

returns a string in which all the matches (use global=no to replace only the first match) are replaced. The function can also be applied to a string-array

Examples:


Replace(some_text, '<i>(.*?)</i>', '<b>\1</b>')  # replaces all html italic with bold.

See also: regular expressions, Split, Match, Field

4.85 Rmsd

[Top]

Rmsd( I )

Rmsd( R )

Rmsd( R w=R )

Rmsd( M [all] )

4.86 Rot

[Top]

Rot( R )

Rot( R r )

Rot( R R r )

4.87 Score

[Top]

Score( v1=R v2=R )

4.88 SendMail

[Top]

SendMail( server=s from=s to=s subject=s body=S )

SendMail( server=s from=s to=s subject=s message=s )

SendMail( server=s from=s to=s subject=s filename=s attach file )

SendMail( server=s from=s to=s subject=s buffer=s attach buffer )

SendMail( server=s header=c body=s attachments=c )

SendMail( server=s user=s pwd=s header=c body=s attachments=c )

4.89 Serialize

[Top]

Serialize( value )

4.90 Sign

[Top]

Sign( i )

Sign( r )

Sign( I )

Sign( R )

4.91 Sin

[Top]

Sin( r )

Sin( R )

4.92 Sinh

[Top]

Sinh( r )

Sinh( R )

4.93 Size

[Top]

4.94 Smooth

[Top]

Options: [window=7]

Smooth( R [window=i] )

Smooth( R weight=R )

Smooth( M [r=3.] [yScale=1.] )

4.95 Sort

[Top]

Options: [compare=null]

Sort( array [] [] [] )

4.96 Split

[Top]

Options: [exact=no,skipEmptyEnds=no,field=0,delimiter="\s+"]

Split( s [delimiter=s] )

Split( s blockSize=i )

4.97 Sprintf

[Top]

Sprintf( format=s )

4.98 Sqrt

[Top]

Sqrt( r )

Sqrt( R )

Sqrt( M )

4.99 Square

[Top]

Square( r )

Square( R )

Square( M )

4.100 Sum

[Top]

Sum( groupBy datacol [keyName='Key'] [dataName='Sum'] )

Sum( S [delimiter=' '] )

4.101 Tan

[Top]

Tan( r )

Tan( R )

4.102 Tanh

[Top]

Tanh( r )

Tanh( R )

4.103 Tensor

[Top]

Tensor( M )

4.104 TestRead

[Top]

TestRead( filename=s )

4.105 Time

[Top]

Time( string )

4.106 Tolower

[Top]

Tolower( i )

Tolower( s [index=i] )

Tolower( S [index=i] )

4.107 Toupper

[Top]

Toupper( i )

Toupper( s [index=i] )

Toupper( S [index=i] )

4.108 Trace

[Top]

Trace( M )

4.109 Trans

[Top]

Trans( transformation=R )

4.110 Transform

[Top]

Transform( toHex {s|S|L} )

Transform( fromHex {s|S} )

Transform( toBase64 {s|S} )

Transform( fromBase64 {s|S} )

4.111 Transpose

[Top]

Transpose( M )

Transpose( R )

4.112 Trim

[Top]

Trim( I min=i max=i )

Trim( R min=r max=r )

Trim( M min=r max=r )

Trim( s [all] )

Trim( s maxLength=i )

Trim( S maxLength=i )

Trim( S [all] )

4.113 Type

[Top]

Type( obj [level=1] )

Type( obj full )

4.114 Unique

[Top]

Unique( array )

Unique( T )

4.115 Unix

[Top]

Unix( cmd=s [redirectStderr=no] )

4.116 Unserialize

[Top]

Unserialize( buffer=s )

4.117 Vector

[Top]

Vector( v1=R v2=R )

Vector( M )

4.118 Version

[Top]

4.119 Volume

[Top]

Volume( radius=r )

Volume( R )


5 Regular expressions

[Top]

Simple expressions (~~c is a character ): Modifiers: 'regexp':i - ignore case, 'regexp':n match newline with dot.

  • . any character except new line ( to match anything, say (.|\n),or '(.*)':n )
  • ^ the beginning of the line
  • $ the end of the line
  • [abc] any character from the list
  • [^abc] any character NOT in the list
  • [a-z] a range, e.g. [0-9] or [0-9A-Z]
  • \c backslash suppresses special meaning of a character
  • \\ backslash itself
  • (string) enclose a simple expression in parentheses to write repetitions or back-references.

Shortcuts

  • \d matches a digit ( '[0-9]' ). '\d+' matches one or more digits.
  • \D matches a NON-digit. '\D+' matches space between numbers
  • \w matches a character in a word ( [a-zA-Z_] ). '\w+' matches a word
  • \W matches a NON-word character. '\W+' matches the interword space
  • \s matches a whitespace character, or a separator ( [ \r\t\n\f] )
  • \S matches a non-separator symbol

Repetitions and back-references ( a and b are simple regular expressions, e.g. a DNA base [ACTG], or ([hp]anky.*) ):

  • a? - nothing or a single a, the largest match
  • a* - nothing or any number of a, the largest match
  • a+ - matches a at least once or more, the largest match
  • a?? - nothing or a single a, the smallest match
  • a*? - nothing or any number of a, the smallest match
  • a+? - matches a at least once or more, the smallest match
  • a{n,m} - matches a from n to m times
  • a|b - matches a or b
  • ab - matches a and b
  • (a)\1 - \1 is a back-reference: matches a, then matches exactly the same string. Back-references can go from \1 to \9.
  • a(?=b) - a pattern a followed by a lookahead pattern b, which is not included in the match
  • (?<=b)a - a pattern a preceded by a lookbehind pattern b


6 System variables

[Top]

[ real.format | date.format ]

real.format contains C-style format string for printing real values.


real.format = "%.2f"
print 1.235;

date.format constains the format for dateinput and output

Date format specification:


%D - day, say 1 or 12 or 30
%DD - day with compulsary two digits, say 01 03 12 etc.
%M - month (say, 1)
%MM - see above at %DD (say 01)
%m - brief month (3 letter), say dec oct etc.
%mm - full month (december)
%Y - four letter year
%y - two letter year (damn with Y2K)
%W - week day (say, Saturday)
%w - three letter day (say, sat )
%HH - always aligned by two chars (03)
%H - one or two chars
%hh - the same with in pm/am style,
%h - the same in pm/am style
%pm - the string "pm" or "am", empty otherwise.
%UU - minutes (say 01)
%U - minutes (say 1, 12 )
%SS - seconds (say 04)
%S - seconds (say 1, 4,12)

Examples:


date.format = "%MM/%DD/%Y"
Date("12/31/1999") #Ok
Date("1/31/1999") # will fail as we specified %MM
date.format = "%MM/%DD/%Y %HH:%UU:%SS"
Date() # will show current date and time like
12/31/1999 12:20:03
string(Date(), date.format = "%Y") # redefining date format only to run string constructor to output date as we need


7 Modules

[Top]

[ Chemistry | Machlearing ]

7.1 Chemistry

[Top]

7.2 Machine Learing

[Top]

Copyright© 1989-2004, Molsoft,LLC - All Rights Reserved. This document contains proprietary and confidential information of Molsoft, LLC. The content of this document may not be disclosed to third parties, copied or duplicated in any form, in whole or in part, without the prior written permission from Molsoft, LLC.