Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Module Overview</h1> <p>Groovy Science is a symbolic manipulation library for Groovy that is intended to be easy to "glue" to existing scientific Java (and Groovy) libraries.</p> <h1>Installing</h1> <p>There are no archive releases of Groovy Science yet, but the current source can be found at <a href="http://svn.codehaus.org/groovy-contrib/science/">http://svn.codehaus.org/groovy-contrib/science/</a>. To use it, you can do any of the following things:</p> <ul> <li>Build it in its own project, and have your project reference that project.</li> <li>Copy the source into your own project.</li> <li>Make a .jar file yourself, and use that.</li> </ul> <h1>Pre-requisites</h1> <p>Groovy Science has been successfully built and used under Java 1.6.0 Update 7 and Groovy 1.5.1.</p> <h1>Documentation</h1> <h2>Building SymbolicExpressions</h2> <p>The centerpiece of the library is the SymbolicExpression class. A SymbolicExpression is a representation of the "application" of an operator object to a list of other SymbolicExpressions. This makes for a simple tree structure, and it is not unlike the way Lisp code is represented in s-expressions.</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.science.SymbolicExpression import static org.codehaus.groovy.science.SymbolicExpression.expr Object plusOp = new Object(); Object leafOp = new Object(); SymbolicExpression leaf = expr( leafOp ); SymbolicExpression myExpression = expr( plusOp, leaf, leaf ); assert myExpression.operator == plusOp; assert myExpression.argumentList == [ leaf, leaf ]; assert myExpression.argumentList[ 0 ].operator == leafOp; assert myExpression.argumentList[ 0 ].argumentList == []; </pre></td></tr></table> <p>The SymbolicExpression class overloads almost all of the operators that can be overloaded in Groovy. So, instead of building all expressions using expr, you can sometimes take advantage of Groovy's own syntax:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.science.SymbolicExpression import static org.codehaus.groovy.science.SymbolicExpression.expr import org.codehaus.groovy.science.OverloadableOperators Object leafOp = new Object(); SymbolicExpression leaf = expr( leafOp ); assert leaf + leaf == expr( OverloadableOperators.Plus, leaf, leaf ); assert leaf[ leaf ] == expr( OverloadableOperators.GetAt, leaf, leaf ); </pre></td></tr></table> <p>If you wanted to represent an expression like "1 + 1", you could do so as follows:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.science.SymbolicExpression import static org.codehaus.groovy.science.SymbolicExpression.expr SymbolicExpression one = expr( 1 ); SymbolicExpression onePlusOne = one + one; </pre></td></tr></table> <p>If you do that, though, you might run the risk of confusing your constants with your other operators. To help keep your constants clearly identified, you can use the ConstantOperator class:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.codehaus.groovy.science.SymbolicExpression import static org.codehaus.groovy.science.SymbolicExpression.expr import org.codehaus.groovy.science.ConstantOperator import static org.codehaus.groovy.science.ConstantOperator.* // for con, unCon, and isCon SymbolicExpression one = con( 1 ); SymbolicExpression onePlusOne = one + one; assert one == expr( new ConstantOperator( 1 ) ); assert one.operator.value == 1; assert unCon( one ) == 1; assert isCon( one ); assert !isCon( onePlusOne ); </pre></td></tr></table> <h1>Developers</h1> <ul> <li>Ross Angle [rokitna at hotmail]</li> </ul> <h1>Source Control</h1> <p><a href="http://svn.codehaus.org/groovy-contrib/science/">http://svn.codehaus.org/groovy-contrib/science/</a></p> <h1>Contributing</h1> <p>Please contact the team members by e-mail.</p> <p>Groovy Science can take a lot of different directions. Here are some of the bigger sub-projects it might encompass:</p> <ul> <li>A toolkit of wrappers that make it easier to use SymbolicExpressions with a particular scientific Java library.</li> <li>A comprehensive or near-comprehensive palette of operators for use with a particular domain, such as expressions involving real numbers, assertions in set theory, or chemical reactions.</li> <li>A new, expressive way to generate SymbolicExpressions "literally" in code, such as by parsing a string or by using AST macros to interpret actual Groovy source code.</li> <li>A new way of visualizing SymbolicExpressions, such as a plain text, TeX, or HTML prettyprinter---or even a way to more easily create such prettyprinters.</li> </ul> <p>In case you don't have a big idea like that or a lot of time to do it in, here are some of the more menial things that could still really help:</p> <ul> <li>Write a build script.</li> <li>Generate the Javadocs. (Javadoc comments are already maintained, but actual HTML hasn't been generated yet.)</li> <li>Write more test cases.</li> <li>Identify code that is in severe need of commenting. If you can, comment it yourself.</li> </ul>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced