![]()
Copyright © 2004, Molsoft LLC Jul 28 2004
|
[ Intruduction | Quickref | Language Reference | Built-in Functions | Regular expressions | System variables | Modules ] Info> string 's' (8725 bytes) is loaded
[ Main types ]
[ integer | real | logical | string | integer-array | real-array | larray | sarray | matrix | collection ] Integer constants can be written in decimal of hex form: a = 0x10 print a,2,-12,1+2 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:
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 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 Matrix has no constant repsentation. M=matrix(3,3,4.2)
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") -- <>
[ Flow control | Index expressions | User functions | User classes | Operations ]
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 [{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:
[ 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 ]
Absolute value function
Examples: a = Abs( -1 ) a = Abs( { 1, -2, -5 } )
Acos( r ) Acos( R )
Acosh( r ) Acosh( R )
Angle( v1=R v2=R ) Angle( p1=R p2=R p3=R )
Asin( r ) Asin( R )
Asinh( r ) Asinh( R )
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] )
Atan( r ) Atan( R )
Atan2( x=r y=r ) Atan2( x=R y=R )
Atanh( r ) Atanh( R )
Augment( transformation=R ) Augment( cell=R ) Augment( xyz=R ) Augment( xyz=M )
Axis( transformation=R ) Axis( rotation=M )
Beta( a=r b=r )
BetaInc( a=r b=r x=r )
BetaLn( a=r b=r )
Ceil( r ) Ceil( r base=r ) Ceil( R ) Ceil( R base=r )
Comp( A B [compare=f] )
Complement( I to=i [from=1] )
Corr( R R ) Corr( R R w=R )
Cos( r ) Cos( R )
Cosh( r ) Cosh( R )
Count( groupBy [keyName='Key'] [dataName='Count'] ) Count( to=i ) Count( from=i to=i )
Crypt( s [simple] ) Crypt( s key=s [simple] )
DateAdd( date=d increment=i part=p ) Redefinition: date.options.part
DateDiff( from=d to=d part=p ) Redefinition: date.options.part
DatePart( date=d part=p ) Redefinition: date.options.part
Decrypt( s key=s [simple] )
Det( M )
Disgeo( M )
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} )
Erfc( r [] ) Erfc( R [] )
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
Existenv( env=s )
Exp( r ) Exp( R ) Exp( M )
Extension( s [dot] ) Extension( S [dot] )
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=''] )
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 )
Floor( r ) Floor( r base=r ) Floor( R ) Floor( R base=r )
Gamma( a=r )
GammaInc( a=r x=r )
GammaLn( a=r )
Gauss( n=i )
Getenv( env=s )
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:
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
Histogram( I ) Histogram( R nCells=i ) Histogram( R cellSize=r ) Histogram( R from=r to=r cellSize=r ) Histogram( R cellRuler=R )
ID2Object( id=s )
Index( array value [] ) Index( s substring ) Index( s substring regexp ) Index( S substring regexp )
Indexx( s find=s [len] )
Insert( list value [name=''] [pos=0] ) Insert( T col [name=''] [pos=0] )
Integral( R x=r ) Integral( y=R x=R )
Join( col col [inner] [columns] )
LinearFit( x=R y=R ) LinearFit( x=R y=R w=R )
Log( r ) Log( r base=r ) Log( R ) Log( R base=r ) Log( R base=i ) Log( M ) Log( M base=r )
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] )
Max( array ) Max( M ) Max( groupColumn dataColumn [groupName='Key'] [dataName='Max'] ) Max( i i ) Max( r r ) Max( array={I|R} max=r )
Mean( x group [names=S] ) Mean( R ) Mean( R w=R ) Mean( I ) Mean( M ) Mean( M [all] )
Median( {R|I} )
Min( array ) Min( M ) Min( groupColumn dataColumn [groupName='Key'] [dataName='Min'] ) Min( i i ) Min( r r ) Min( array={I|R} min=r )
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] )
Mod( i ) Mod( i divider=i ) Mod( r ) Mod( r divider=r ) Mod( I ) Mod( I divider=i ) Mod( R ) Mod( R divider=r )
Money( r [format='$%.m'] )
Name( collection field=i )
Nof( object [element] )
Object2ID( object )
Path( s )
Percentile( {R|I} percent=r )
Power( I ) Power( base exp )
Putenv( env=s ) Putenv( name=s value )
Quantile( {R|I} position=i )
RaiseError( message=s )
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 )
ReactionRead( filename=s )
Regexp( string=s [flags=''] )
Remainder( i [divider=i] ) Remainder( r [divider=r] ) Remainder( I [divider=i] ) Remainder( R [divider=r] )
ReopenTable( table=B )
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:
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
Rmsd( I ) Rmsd( R ) Rmsd( R w=R ) Rmsd( M [all] )
Rot( R ) Rot( R r ) Rot( R R r )
Score( v1=R v2=R )
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 )
Serialize( value )
Sign( i ) Sign( r ) Sign( I ) Sign( R )
Sin( r ) Sin( R )
Sinh( r ) Sinh( R )
Options: [window=7] Smooth( R [window=i] ) Smooth( R weight=R ) Smooth( M [r=3.] [yScale=1.] )
Options: [compare=null] Sort( array [] [] [] )
Options: [exact=no,skipEmptyEnds=no,field=0,delimiter="\s+"] Split( s [delimiter=s] ) Split( s blockSize=i )
Sprintf( format=s )
Sqrt( r ) Sqrt( R ) Sqrt( M )
Square( r ) Square( R ) Square( M )
Sum( groupBy datacol [keyName='Key'] [dataName='Sum'] ) Sum( S [delimiter=' '] )
Tan( r ) Tan( R )
Tanh( r ) Tanh( R )
Tensor( M )
TestRead( filename=s )
Time( string )
Tolower( i ) Tolower( s [index=i] ) Tolower( S [index=i] )
Toupper( i ) Toupper( s [index=i] ) Toupper( S [index=i] )
Trace( M )
Trans( transformation=R )
Transform( toHex {s|S|L} ) Transform( fromHex {s|S} ) Transform( toBase64 {s|S} ) Transform( fromBase64 {s|S} )
Transpose( M ) Transpose( R )
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] )
Type( obj [level=1] ) Type( obj full )
Unique( array ) Unique( T )
Unix( cmd=s [redirectStderr=no] )
Unserialize( buffer=s )
Vector( v1=R v2=R ) Vector( M )
Volume( radius=r ) Volume( R )
Simple expressions (~~c is a character ): Modifiers: 'regexp':i - ignore case, 'regexp':n match newline with dot.
Shortcuts
Repetitions and back-references ( a and b are simple regular expressions, e.g. a DNA base [ACTG], or ([hp]anky.*) ):
[ 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
[ Chemistry | Machlearing ]
|
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. |