packages feed

husky-0.4: doc/usage.html

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>husky command line calculator</title>
<meta name="author" content="Markus Dittrich" />
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left {
  clear: left }

img.align-right {
  clear: right }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font-family: serif ;
  font-size: 100% }

pre.literal-block, pre.doctest-block {
  margin-left: 2em ;
  margin-right: 2em }

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="husky-command-line-calculator">
<h1 class="title">husky command line calculator</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Markus Dittrich</td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.4 (04/04/2009)</td></tr>
</tbody>
</table>
<div class="section" id="introduction">
<h1>Introduction</h1>
<p>husky is a command line calculator with a small memory
footprint. It can be used in a fashion similar to the
interactive shells of python, octave, or ghci.</p>
</div>
<div class="section" id="functionality">
<h1>Functionality</h1>
<p>Husky presently can be used as</p>
<ol class="arabic simple">
<li>calculator</li>
<li>unit converter</li>
</ol>
<p>The following sections describe in detail each functionality.</p>
<div class="section" id="calculator">
<h2>Calculator</h2>
<div class="section" id="basic-functionality">
<h3>Basic Functionality</h3>
<p>Currently, the mathematical operations &quot;+&quot;, &quot;-&quot;, &quot;*&quot;, and
&quot;/&quot; are supported with arbitrary nesting of parenthesised
expressions. All calculations are performed in double
precision. In addition to the standard operations above,
the following functions are currently supported:</p>
<ul class="simple">
<li><em>sqrt</em> : square root</li>
<li><em>a^n</em> : exponentiation (n can be arbitrary double)</li>
<li><em>exp</em> : exponential function</li>
<li><em>ln, log2, log10</em> : natural, base2, and base10 logarithm</li>
<li><em>cos, sin, tan, acos, asin, atan</em>: trigonometric functions and inverse</li>
<li><em>cosh, sinh, tanh, acosh, asinh, atanh</em>: hyperbolic trigonometric functions and inverse</li>
<li><em>fact n</em>: factorial function. NOTE: <em>n</em> has to be an integer or be convertible to an integer type, i.e., <em>fact 2</em> and <em>fact 2.0</em> are fine but <em>fact 2.1</em> is not.</li>
</ul>
</div>
<div class="section" id="variables">
<h3>Variables</h3>
<p>Users can define any number of variables via</p>
<blockquote>
<em>variable name</em> = value</blockquote>
<p>where variable name can be any combination of alphanumeric
characters but has to begin with a letter. Hence, <em>foobar1</em>
is fine, but <em>1foobar</em> is not. Defined variables can be
used in expressions and definition of other variables. Users
can list all currently defined variables via \v (see
<a class="reference internal" href="#command-shortcuts">Command Shortcuts</a>)</p>
<p>Since husky uses the GNU readline library all readline
related functionality is available at husky's interactive
prompt (including command history). See <a class="footnote-reference" href="#id2" id="id1">[1]</a> for more
detail.</p>
</div>
<div class="section" id="functions">
<h3>Functions</h3>
<p>Users can define their own custom functions via the syntax</p>
<blockquote>
<em>function &lt;function name&gt; &lt;list of variables&gt; = &lt;expression&gt;</em></blockquote>
<p>Here, the list of variables can either be a comma separated list
of variable names enclosed in parentheses or a simple list of
variables separated by whitespace without parentheses like in
Haskell. The following expressions are valid and equivalent
function definitions</p>
<pre class="literal-block">
f(x,y) = x * y
f x y  = x * x
</pre>
<p>Several restrictions currently apply to function definitions:</p>
<ul class="simple">
<li><em>&lt;expression&gt;</em> can only span a single line and will be parsed
until the end of the line.</li>
<li><em>&lt;expression&gt;</em> has to be a single expression, i.e., it can <strong>not</strong>
contain a list of semicolon separated expressions.</li>
</ul>
<p>Functions which have been defined can then be called according to
the same conventions used for function definitions. Hence, function
f as defined above can be called via</p>
<blockquote>
f(3,2) or f 3 2</blockquote>
<p>Here, the calling method does not depend on the way the function
was defined, i.e., a function could be defined the Haskell way and
then be called via f(x,y). The function arguments can either be
literals or constants that have been defined previously. Hence,
the following husky session is valid</p>
<pre class="literal-block">
a = 3
b = 4
function f x y = x * y
f(a,b)
</pre>
<p>will yield the value &quot;12.0&quot;.</p>
<p>Users can list all presently defined function via \f (see
<a class="reference internal" href="#command-shortcuts">Command Shortcuts</a>).</p>
</div>
</div>
<div class="section" id="unit-converter">
<h2>Unit Converter</h2>
<p>The unit conversion functionality of husky can be used via the
command</p>
<blockquote>
\c[onvert] <em>&lt;unit value&gt;</em> <em>&lt;from unit&gt;</em> <em>&lt;to unit&gt;</em> [ :: <em>&lt;unit type&gt;</em>]</blockquote>
<p>Here, we convert <em>&lt;unit value&gt;</em> in units of <em>&lt;from unit&gt;</em> to the
target unit <em>&lt;to unit&gt;</em>. In addition, the user may further specify
the unit type (e.g. Length, Time, ...) to disambiguate a unit
conversion request. The space between <em>&lt;unit value&gt;</em> and <em>&lt;from unit&gt;</em>
is optional. E.g.:</p>
<pre class="literal-block">
\c 1m yd
\c 1 m yd
\c 1 m yd :: Length
</pre>
<p>will all convert 1 meter into yards. Please type:</p>
<pre class="literal-block">
\h[elp] units
</pre>
<p>for a list of all unit conversions.</p>
</div>
</div>
<div class="section" id="command-shortcuts">
<h1>Command Shortcuts</h1>
<p>The following commands are available at the command prompt:</p>
<ul class="simple">
<li>\q       : quit husky</li>
<li>\v       : list all currently defined variables</li>
<li>\f       : list all currently defined functions</li>
<li>\t       : current time</li>
<li>\h[elp]  : available help</li>
</ul>
</div>
<div class="section" id="copyright-and-license">
<h1>COPYRIGHT and LICENSE</h1>
<p>(C) 2008-2009, Markus Dittrich</p>
<p>This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License Version 3 as published by the Free Software Foundation.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License Version 3 for more details.</p>
</div>
<div class="section" id="bugs">
<h1>BUGS</h1>
<p>Please report all bugs to &lt;<a class="reference external" href="mailto:haskelladdict&#64;gmail.com">haskelladdict&#64;gmail.com</a>&gt;. Thank you!</p>
</div>
<div class="section" id="references">
<h1>References</h1>
<table class="docutils footnote" frame="void" id="id2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>The GNU readline library
<a class="reference external" href="http://tiswww.case.edu/php/chet/readline/rltop.html">http://tiswww.case.edu/php/chet/readline/rltop.html</a></td></tr>
</tbody>
</table>
</div>
</div>
</body>
</html>