Mapytex/mapytex/calculus/core/__init__.py

76 lines
1.2 KiB
Python
Raw Normal View History

2018-01-21 08:26:34 +00:00
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 lafrite <lafrite@Poivre>
#
# Distributed under terms of the MIT license.
2018-09-17 14:27:08 +00:00
r"""
2018-01-21 08:26:34 +00:00
Abstracts tools for calculs manipulations
2018-09-17 14:27:08 +00:00
:example:
>>> t = Tree.from_str("2+3*4")
>>> print(t)
+
> 2
> *
| > 3
| > 4
>>> print(t.apply_on_last_level(compute))
2018-09-17 14:27:08 +00:00
+
> 2
> 12
>>> tree2txt(t)
'2 + 3 * 4'
>>> tree2tex(t)
'2 + 3 \\times 4'
>>> t = Tree.from_str("2+3/4")
>>> print(t)
+
> 2
> /
| > 3
| > 4
>>> print(t.apply_on_last_level(compute))
+
> 2
> /
| > 3
| > 4
>>> tt = t.apply_on_last_level(typing)
>>> print(tt.apply_on_last_level(compute))
+
> 2 / 1
> 3 / 4
>>> type(t.right_value)
<class 'mapytex.calculus.core.tree.Tree'>
>>> type(tt.right_value)
<class 'mapytex.calculus.core.MO.fraction.MOFraction'>
>>> tt.right_value
<MOFraction 3 / 4>
2018-09-20 16:27:40 +00:00
>>> t = Tree.from_str("2+3x")
>>> print(t)
+
> 2
> *
| > 3
| > x
2018-09-17 14:27:08 +00:00
2018-01-21 08:26:34 +00:00
"""
from .tree import Tree, AssocialTree
2018-09-17 14:27:08 +00:00
from .compute import compute
from .typing import typing, TypingError
2018-09-17 14:27:08 +00:00
from .renders import tree2txt, tree2tex
from .random import list_generator as random_list
2018-09-17 14:27:08 +00:00
2018-01-21 08:26:34 +00:00
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del