Skip to content

Commit 7a04774

Browse files
committed
Merge pull request #651 from Huaraz2/SageMath
Adding language support for Sage
2 parents cc1b2fb + 26addb8 commit 7a04774

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Currently supported grammars are:
5959
* Ruby
6060
* Ruby on Rails
6161
* Rust
62+
* Sage
6263
* Sass/SCSS <sup>[*](#asterisk)</sup>
6364
* Scala
6465
* Swift

examples/example.sage

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def isinverse(matrix):
2+
"""
3+
This function checks if a matrix has an inverse and if it does it outputs it, if not returns FALSE.
4+
5+
arguements: A matrix
6+
7+
outputs: if inverse exists - the invese of the matrix
8+
inverse doesn't exist - this matrix has no inverse
9+
"""
10+
11+
try:
12+
return matrix.inverse()
13+
except:
14+
return "This matrix has no inverse"
15+
16+
C = matrix([[-1/2, -1/2], [-2, -1]])
17+
print isinverse(C)
18+
print "The determinant of this matrix is:"
19+
print det(C)
20+
21+
D = matrix([[2, -2, 1], [6, -1, 1], [12, -2, 2]])
22+
print isinverse(D)
23+
print "The determinant of this matrix is:"
24+
print det(D)
25+
26+
E = matrix([[1, 2], [2, 0]])
27+
print isinverse(E)
28+
print "The determinant of this matrix is:"
29+
print det(E)

lib/grammars.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ module.exports =
416416
command: "make"
417417
args: (context) -> ['-f', context.filepath]
418418

419+
Sage:
420+
"Selection Based":
421+
command: "sage"
422+
args: (context) -> ['-c', context.getCode()]
423+
"File Based":
424+
command: "sage"
425+
args: (context) -> [context.filepath]
426+
419427
Sass:
420428
"File Based":
421429
command: "sass"

0 commit comments

Comments
 (0)