Fonctionel !!!

pull/1/head
Jean-Christophe Jameux 4 years ago
parent cf3c845260
commit 32bc802fd0
  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.elmi
  4. BIN
      elm-stuff/0.19.1/QCM.elmo
  5. BIN
      elm-stuff/0.19.1/d.dat
  6. 26
      src/ParserMaths.elm
  7. 34
      src/QCM.elm

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,10 +1,11 @@
module ParserMaths exposing (parseMaths, evaluer, montrerErreurs)
module ParserMaths exposing (parseMaths, evaluer, evaluerBis, montrerErreurs, expr)
import Fractions as F
import Fractions as F exposing (Frac)
import Maybe as M
import Set
import Parser exposing (..)
montrerErreurs : String -> List DeadEnd -> String
montrerErreurs source errs =
case List.head errs of
@ -32,6 +33,11 @@ displayExpected err =
_ ->
"une expression"
evaluerBis : Expr -> F.Frac
evaluerBis expression =
case evaluer expression of
Nothing -> Frac 666 1
Just a -> a
evaluer : Expr -> Maybe F.Frac
evaluer expression =
@ -65,6 +71,22 @@ evaluer expression =
Poly a_i x ->
Just <| F.Frac 50 1
{--
type Expr
= Const Fraction
| Var String
| Poly (List Fraction) String
| Exp Expr
| Ln Expr
| Sin Expr
| Cos Expr
| Prod Expr Expr
| Div Expr Expr
| Sum Expr Expr
| Dif Expr Expr
| Exp Expr Frac
| Opp Expr
--}
type Expr
= Add Expr Expr

@ -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, iframe)
import Html exposing (Html, Attribute, button, div, textarea, input, p, iframe)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
@ -84,6 +84,7 @@ view model =
<| textarea [ placeholder "Liste des variables", value model.variables, onInput Variables ] []
:: textarea [ placeholder "Format de la question", value model.question, onInput Question ] []
:: button [ onClick GenererQuestion ] [ text "Générer les questions" ]
:: (text "Le résultat apparaitra\nici")
:: [ ( p [] <| L.map (\q -> p [] [text q]) model.questions ) ]
{--
:: text
@ -143,6 +144,12 @@ mix lls =
(a :: ls) :: llss -> ( List.map ( (::) a ) ( mix llss ) ) ++ mix ( ls :: llss )
-}
text chaine =
S.lines chaine
|> L.map (p [] << L.singleton << Html.text)
|> p []
{-
@ -229,7 +236,7 @@ parserAremplacer variables =
aRemplacer : Parser Aremplacer
aRemplacer =
succeed Aremplacer
succeed ( \x y -> Aremplacer x (L.map (F.teX << PM.evaluerBis) y) )
|. P.spaces
|= P.variable
{ start = \_ -> True
@ -243,11 +250,14 @@ aRemplacer =
, separator = ","
, end = ""
, spaces = spaces
, item = PM.expr
{--
, item = P.variable
{ start = (/=) ','
, inner = (/=) ','
, reserved = Set.fromList []
}
--}
, trailing = P.Optional
}
@ -312,23 +322,6 @@ remplacerLaVariableParLaValeurDansLeTexteVariable var val tv =
-}
type Nombre
=
type Expr num
= Const num
| Var String
| Poly ( List num )
| Exp ( Expr num )
| Ln ( Expr num )
| Sin ( Expr num )
| Cos ( Expr num )
| Prod ( Expr num ) ( Expr num )
| Quot ( Expr num ) ( Expr num )
| Sum ( Expr num ) ( Expr num )
| Diff ( Expr num ) ( Expr num )
| Power ( Expr num ) num
monome a n =
if a == 0 then ""
else if n == 0 then ( String.fromInt a )
@ -385,15 +378,12 @@ dlGen a_ks n =
{-
-}

Loading…
Cancel
Save