Skip to content

Latest commit

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

computerV2

Dependencies

The dependencies you need are haskell and stack.
To get them, check https://www.haskell.org/platform/
You also need cairo:

  • sudo apt-get install libghc-cairo-dev for ubuntu
  • brew install cairo for MacOS

Project

To start the project use:
git clone https://github.com/glegendr/ComputerV2.git; cd ComputerV2; sh compile.sh
You will get a binary call ComputerV2

Variables

Types

There is 4 types of variables:

TypeSetDescription
RationalsQNumber that can be expressed as the quotient or fraction p/q of two integers, a numerator p and a non-zero denominator q
Imaginarya + ib -> (a, b) ∈ Q^2Complex number that can be written as a real number multiplied by the imaginary unit i
MatrixA ∈ Mn,p(Q)Rectangular array of numbers, symbols, or expressions, arranged in rows and columns
FunctionsFunction with one argument

Creation

> {variableName} = {variableValue}
To create a variable, you have to give the name followed by the value.
You can give a computation as value.
All variables name are not case sensitive.

Rational:

> myVar = 4 + 23.5
27.5
> myVarB = myVar - 50
-22.5

Imaginary:

> myIma = 3i + 42
42.0 + 3.0i
> myImaB = myIma^2 1755.0 + 252.0i 

Matrix:

> mat = [[1,2,3];[4,5,6]]
[1.0,2.0,3.0]
[4.0,5.0,6.0]
> matB = mat ** [[1];[2];[3]]
[14.0]
[32.0]

Functions:

> f(x) = 42x + 21
42.0x + 21.0 > myFunctionB(myVariableName) = myVariableName * (4 + 2)
6.0myvariablename 

If you create a variable that already exist, the older one will be overwritten.

Computation

> {computationA} = {computationB} ?
The computation part allows you to:

  • Display the value of calculation
  • Check if the first part of the computation is the same as the second one
  • Solve quadratic equation
> 43 + 53/2 = ?
69.5
> [[1.0,2.0,3.0],[4.0,5.0,6.0]]** [[1];[2];[3]] = [[14.0];[32.0]] ?
True
> 4x + 32 - 2x^2 = 0 ?
Reduced Form: -2.0x^2 + 4.0x + 32.0 = 0
The two solutions are:
5.1231055
-3.1231055

Commands

All Commands

> {commandName}:{commandArg1}:{commandArg2}:...:{commandArgN}

NameDescription
helpDisplay help message
listList all existing variables
historyList all given input except commands
delDel a variable
replaceReplace variable name by an other
showCreate a plot
quitQuit the program

Help Command

> help:{helpArgs}
This command displays help

ShortMediumLongDescription
hhelpDisplay this message
ccommandsList all existing command
llistDisplay the command list
ihistoryDisplay the command history
ddelDisplay the command del
rreplaceDisplay the command replace
sshowDisplay the command show
qquitDisplay the command quit
oopeoperatorsDisplay all operators
?computationDisplay how to compute

List Command

> list:{listArgs}
List all existing variables

ShortMediumLongDescription
rratrationalsList all exsting rationals
iimaimaginaryList all exsting imaginary
mmatmatrixList all exsting matrix
ffctfunctionsList all exsting functions
ccstconstantsList all exsting constants
aallList all exsting var and constants

History Command

> history:{historyArgs}
List all given input except commands, excluding del and replace

The only argument taken is the number of input you want to display.

  • N: List N last input

Default is the list of all input.

Del Command

> del:{delArgs}
The del command delete a named variable or a pull of variables

ShortMediumLongDescription
XDelete variable with name X
aallDelete all variables
ddupduplicateDelete all duplicates

Replace Command

> replace:{replaceArgs}
The replace command replace the name of a variable by another.
If the chosen name is already a variable, the two names will swap each other.

The only argument taken by replace is the current name of the variable and the new one.

  • X:Y Replace var name X by Y. If Y exist the 2 name are swapping

Show Command

> show:{showArgs}
The show command creates a plot of the given fuction

ShortMediumLongDescriptionDefault
f=x,y..fct=x,y..function=x,y..Function to display
o=xout=xoutput=xName of created fileCreation date or title if set
t=xtitle=xTitle of the graphCreation date or output if set
min=xStart of the X axis-100
max=xEnd of the X axis100
down=xStart of the Y axis-∞
up=xEnd of the Y axis
s=xscale=xScaling between each calculation dot((min - max) / 2000)

The plot is a SVG file created at charts/{output}.svg

For example, the command
> show:function=f:min=-7.5:max=7.4:down=-20:up=20:title=boomerang:scale=0.0025
would display:

You can also use more than one function as:
> show:function=f,z:min=-7.5:max=7.4:down=-20:up=20:title=star:scale=0.0025
would display:

where

> f(x) = 1/x
x^-1 > z(x) = -1/x
-x^-1

Quit Command

> quit
Quit the program.

Author

@glegendr

About

ComputerV2 - 42 project

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages