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. 3463
      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 Fractions as F
import Maybe as M import Maybe as M
import Set
import Parser exposing (..) import Parser exposing (..)
montrerErreurs : String -> List DeadEnd -> String montrerErreurs : String -> List DeadEnd -> String
@ -61,6 +62,9 @@ evaluer expression =
Entier n -> Entier n ->
Just <| F.Frac n 1 Just <| F.Frac n 1
Poly a_i x ->
Just <| F.Frac 50 1
type Expr type Expr
= Add Expr Expr = Add Expr Expr
@ -71,6 +75,7 @@ type Expr
| Neg Expr | Neg Expr
| Entier Int | Entier Int
| Grouping Expr | Grouping Expr
| Poly (List Expr) String
parseMaths : String -> Result (List DeadEnd) Expr parseMaths : String -> Result (List DeadEnd) Expr
@ -96,6 +101,10 @@ type Operand
| Operand Operator Expr | 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 : Expr -> Operand -> Expr
binary a b = binary a b =
case b of case b of
@ -129,6 +138,7 @@ add =
|= loop [] addHelper |= loop [] addHelper
--
foldBinary : Expr -> List Operand -> Expr foldBinary : Expr -> List Operand -> Expr
foldBinary left operands = foldBinary left operands =
List.foldr List.foldr
@ -210,6 +220,7 @@ primary =
] ]
|= oneOf |= oneOf
[ grouping [ grouping
, poly
, nombre , nombre
] ]
@ -225,6 +236,26 @@ nombre =
, float = Nothing , 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 : Parser Expr
grouping = grouping =

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

Loading…
Cancel
Save