About: Calculate equations from within vim   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Equations can span multiple lines, and the full bc syntax is probably supported. Additionally, sin (), cos (), etc, are transformed into the names used by bc (s () c (), etc). Here are some example lines: 2 * sqrt (2) = 3 * (2 - 1) + 4.0 ^ 6 = 4 / 3 = 3 + 4 - 2 * (1 / (3 + 2)) = define rad (x) { return (x / 180) * 4 * atan (1) } cos (rad (45)) = Select each of these in turn and hit ;bc for each. This is what you get: Here is the code you need to put in your vimrc file:

AttributesValues
rdfs:label
  • Calculate equations from within vim
rdfs:comment
  • Equations can span multiple lines, and the full bc syntax is probably supported. Additionally, sin (), cos (), etc, are transformed into the names used by bc (s () c (), etc). Here are some example lines: 2 * sqrt (2) = 3 * (2 - 1) + 4.0 ^ 6 = 4 / 3 = 3 + 4 - 2 * (1 / (3 + 2)) = define rad (x) { return (x / 180) * 4 * atan (1) } cos (rad (45)) = Select each of these in turn and hit ;bc for each. This is what you get: Here is the code you need to put in your vimrc file:
Version
  • 5(xsd:double)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 215(xsd:integer)
Author
  • scotch2
Complexity
  • basic
Created
  • 2002-02-16(xsd:date)
ID
  • 216(xsd:integer)
NEXT
  • 217(xsd:integer)
Rating
  • 12(xsd:integer)
abstract
  • Equations can span multiple lines, and the full bc syntax is probably supported. Additionally, sin (), cos (), etc, are transformed into the names used by bc (s () c (), etc). Here are some example lines: 2 * sqrt (2) = 3 * (2 - 1) + 4.0 ^ 6 = 4 / 3 = 3 + 4 - 2 * (1 / (3 + 2)) = define rad (x) { return (x / 180) * 4 * atan (1) } cos (rad (45)) = Select each of these in turn and hit ;bc for each. This is what you get: 2 * sqrt (2) = 2.82842712474619009760 3 * (2 - 1) + 4.0 ^ 6 = 4099.000000 4 / 3 = 1.33333333333333333333 3 + 4 - 2 * (1 / (3 + 2)) = 6.60000000000000000000 define rad (x) { return (x / 180) * 4 * atan (1) } cos (rad (45)) = .70710678118654752440 Here is the code you need to put in your vimrc file: vnoremap ;bc "ey:call CalcBC() function! CalcBC() let has_equal = 0 " remove newlines and trailing spaces let @e = substitute (@e, " ", "", "g") let @e = substitute (@e, '\s*$', "", "g") " if we end with an equal, strip, and remember for output if @e =~ "=$" let @e = substitute (@e, '=$', "", "") let has_equal = 1 endif " sub common func names for bc equivalent let @e = substitute (@e, '\csin\s*(', "s (", "") let @e = substitute (@e, '\ccos\s*(', "c (", "") let @e = substitute (@e, '\catan\s*(', "a (", "") let @e = substitute (@e, "\cln\s*(", "l (", "") " escape chars for shell let @e = escape (@e, '*()') " run bc, strip newline let answer = substitute (system ("echo " . @e . " \| bc -l"), " ", "", "") " append answer or echo if has_equal == 1 normal `> exec "normal a" . answer else echo "answer = " . answer endif endfunction
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software