pull/1/head
Jean-Christophe Jameux 4 years ago
parent 88356293e6
commit cf3c845260
  1. BIN
      elm-stuff/0.19.1/ParserMaths.elmi
  2. BIN
      elm-stuff/0.19.1/ParserMaths.elmo
  3. BIN
      elm-stuff/0.19.1/QCM.elmo
  4. BIN
      elm-stuff/0.19.1/d.dat
  5. 5233
      elm.js
  6. 1
      elm.min.js
  7. 3625
      index.html
  8. 7360
      qcm.js
  9. 1
      qcm.min.js
  10. 1
      qcmUgly.js
  11. 31
      src/ParserMaths.elm
  12. 9
      src/QCM.elm

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

5233
elm.js

File diff suppressed because it is too large Load Diff

1
elm.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

7360
qcm.js

File diff suppressed because it is too large Load Diff

1
qcm.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2,6 +2,7 @@ module ParserMaths exposing (parseMaths, evaluer, montrerErreurs)
import Fractions as F
import Maybe as M
import Set
import Parser exposing (..)
montrerErreurs : String -> List DeadEnd -> String
@ -61,6 +62,9 @@ evaluer expression =
Entier n ->
Just <| F.Frac n 1
Poly a_i x ->
Just <| F.Frac 50 1
type Expr
= Add Expr Expr
@ -71,6 +75,7 @@ type Expr
| Neg Expr
| Entier Int
| Grouping Expr
| Poly (List Expr) String
parseMaths : String -> Result (List DeadEnd) Expr
@ -96,6 +101,10 @@ type Operand
| Operand Operator Expr
{-
En quelque sorte, décurryfie une expression binaire
binary e_1 (Operand MulOp e_2) == Mul e_1 e_2
-}
binary : Expr -> Operand -> Expr
binary a b =
case b of
@ -129,6 +138,7 @@ add =
|= loop [] addHelper
--
foldBinary : Expr -> List Operand -> Expr
foldBinary left operands =
List.foldr
@ -210,6 +220,7 @@ primary =
]
|= oneOf
[ grouping
, poly
, nombre
]
@ -225,6 +236,26 @@ nombre =
, float = Nothing
}
poly : Parser Expr
poly =
succeed Poly
|. keyword "Poly"
|. spaces
|= sequence
{ start = "["
, separator = ","
, end = "]"
, spaces = spaces
, item = lazy (\_ -> expr)
, trailing = Forbidden
}
|. spaces
|= variable
{ start = \_ -> True
, inner = \_ -> False
, reserved = Set.fromList []
}
grouping : Parser Expr
grouping =

@ -7,7 +7,7 @@ import Set
import ParserMaths as PM
import String as S
import Fractions as F exposing (Frac)
import Html exposing (Html, Attribute, button, div, textarea, input, text, p)
import Html exposing (Html, Attribute, button, div, textarea, input, text, p, iframe)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
@ -244,8 +244,8 @@ aRemplacer =
, end = ""
, spaces = spaces
, item = P.variable
{ start = \x -> Char.isDigit x || x == '-'
, inner = Char.isDigit
{ start = (/=) ','
, inner = (/=) ','
, reserved = Set.fromList []
}
, trailing = P.Optional
@ -312,6 +312,9 @@ remplacerLaVariableParLaValeurDansLeTexteVariable var val tv =
-}
type Nombre
=
type Expr num
= Const num
| Var String

Loading…
Cancel
Save