Giter VIP home page Giter VIP logo

learn-ocaml-corpus's Introduction

The Learn OCaml Corpus

CI

learn-ocaml-corpus's People

Contributors

altgr avatar erikmd avatar fpottier avatar hernoufm avatar radiopotin avatar yurug avatar zazedd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-ocaml-corpus's Issues

Test is missing for the function "reorder" of the exercice "Tetragon"

Hi,

I actually test  Introduction te Functionnal Programming (MOOC) . The exercice  Tetragon  asks to write a function reorder . The verification test is incomplete, because all values that this incorrect function returns are considered as correct in the report :

let reorder (p1, p2, p3, p4) = 
  let l = List.sort (fun p p' -> compare (fst p) (fst p')) [p1; p2; p3; p4] in
  let llp = List.nth l 0 in
  let lup = List.nth l 1 in
  let rup = List.nth l 2 in
  let rlp = List.nth l 3 in
  (lup, rup, llp, rlp);;

If you test this function with a well formed tetragon, the points become disordered :

reorder  ((-4,3), (4,4), (-3,-2), (3,-4));;
- : (int * int) * (int * int) * (int * int) * (int * int) = ((-3, -2), (3, -4), (-4, 3), (4, 4))

Maybe teatchers of this exercice should add this test ?

bug_reorder_function

counting_trees's grader fails with current master of learn-ocaml

Setup

Actual behavior

I've tried starting the grader for each exercise with an (empty) solution, and counting_tree fails with the error below.

Screenshot

2019-08-19_01-21-56_Screenshot_learn-ocaml-corpus_counting-trees

Report tab
Error in the exercise while testing your solution


val print_html : 'a -> 'b = <fun>
type tree = Leaf | Node of tree * tree
exception TODO
module Code : sig  end
module Solution :
  sig
    val weight : tree -> int
    val height : tree -> int
    val naive_trees_of_weight : int -> int
    val trees_of_weights : int -> int array
    val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b
    val sigma : int -> int -> (int -> int) -> int
    val split_weight : int -> (int -> int -> int) -> int
    val trees_of_weight : int -> int
    val tabulate : (int -> 'a) -> int -> int -> 'a list
    val trees_of_weight_0_19 : int list
    val split_wb_weight : int -> (int -> int -> int) -> int
    val wb_trees_of_weight : int -> int
    val wb_trees_of_weight_0_19 : int list
  end
module Test_lib : Test_lib.S
module Report = Learnocaml_report
val iter : ('a -> unit) -> 'a list -> unit = <fun>
val map : ('a -> 'b) -> 'a list -> 'b list = <fun>
module T = Test_lib
module R = Report
type report = R.t
type requirement = int
val infinity : requirement = 2147483647
val ( ++ ) : requirement -> requirement -> requirement = <fun>
val ( <== ) : requirement -> int -> bool = <fun>
type document =
    Empty
  | FancyString of string * int * int * int
  | Blank of int
  | IfFlat of document * document
  | HardLine
  | Cat of requirement * document * document
  | Nest of requirement * int * document
  | Group of requirement * document
val requirement : document -> requirement = <fun>
val empty : document = Empty
val fancysubstring : string -> int -> int -> int -> document = <fun>
val fancystring : string -> int -> document = <fun>
val utf8_length : string -> int = <fun>
val utf8string : string -> document = <fun>
val utf8format : ('a, unit, string, document) format4 -> 'a = <fun>
val char : char -> document = <fun>
val space : document = FancyString (" ", 0, 1, 1)
val semicolon : document = FancyString (";", 0, 1, 1)
val hardline : document = HardLine
val blank : int -> document = <fun>
val ifflat : document -> document -> document = <fun>
val internal_break : int -> document = <fun>
val break0 : document = IfFlat (Empty, HardLine)
val break1 : document = IfFlat (FancyString (" ", 0, 1, 1), HardLine)
val break : int -> document = <fun>
val ( ^^ ) : document -> document -> document = <fun>
val nest : int -> document -> document = <fun>
val group : document -> document = <fun>
val blank_length : int = 80
val blank_buffer : string =
  "                                                                                "
val blanks : Buffer.t -> int -> unit = <fun>
type state = {
  width : int;
  mutable column : int;
  mutable output : Buffer.t;
}
val pretty : state -> int -> bool -> document -> unit = <fun>
val pretty : int -> document -> string = <fun>
val concat : document list -> document = <fun>
val comma : document =
  Cat (2, FancyString (",", 0, 1, 1),
   IfFlat (FancyString (" ", 0, 1, 1), HardLine))
val pre_comma : document -> document = <fun>
val pre_commas : document list -> document = <fun>
val commas : document list -> document = <fun>
val int : int -> document = <fun>
val block : document -> document = <fun>
val parens : document -> document = <fun>
val ocaml_array_brackets : document -> document = <fun>
val tuple : document list -> document = <fun>
val construct : string -> document list -> document = <fun>
val wrap : ('a -> document) -> 'a -> string = <fun>
exception Fail of report
val section : string -> R.t -> report = <fun>
val fail : R.inline list -> 'a = <fun>
val fail_text : ('a, unit, string, 'b) format4 -> 'a = <fun>
val protect : (unit -> report) -> report = <fun>
val successful_status : R.status -> bool = <fun>
val successful_item : R.item -> bool = <fun>
val successful : R.t -> bool = <fun>
val ( -@> ) : report -> (unit -> report) -> report = <fun>
val grab :
  'a Ty.ty -> string -> ('a -> Learnocaml_report.t) -> Learnocaml_report.t =
  <fun>
val test_value_0 :
  string -> 'a Ty.ty -> 'b -> ('a -> 'b -> bool) -> Learnocaml_report.t =
  <fun>
val correct : string -> R.item list = <fun>
val mismatch :
  string ->
  'a -> 'b -> 'b -> int -> ('a -> R.inline list) -> ('b -> string) -> 'c =
  <fun>
val codebreak : ('a -> string) -> 'a -> R.inline list = <fun>
val test_value_1 :
  string ->
  ('a -> 'b) Ty.ty ->
  ('a -> 'b) ->
  ('a -> string) ->
  ('b -> string) -> ('b -> 'b -> bool) -> 'a list -> Learnocaml_report.t =
  <fun>
val test_value_2 :
  string ->
  ('a -> 'b -> 'c) Ty.ty ->
  ('a -> 'b -> 'c) ->
  ('a -> string) ->
  ('b -> string) ->
  ('c -> string) ->
  ('c -> 'c -> bool) -> ('a * 'b) list -> Learnocaml_report.t = <fun>
val test_value_3 :
  string ->
  ('a -> 'b -> 'c -> 'd) Ty.ty ->
  ('a -> 'b -> 'c -> 'd) ->
  ('a -> string) ->
  ('b -> string) ->
  ('c -> string) ->
  ('d -> string) ->
  ('d -> 'd -> bool) -> ('a * 'b * 'c) list -> Learnocaml_report.t = <fun>
val flat_map : ('a -> 'b list) -> 'a list -> 'b list = <fun>
val upk : int -> int -> int list -> int list = <fun>
val up : int -> int -> int list = <fun>
val pairs : 'a list -> 'b list -> ('a * 'b) list = <fun>
val split : int -> (int -> int -> 'a list) -> 'a list = <fun>
val deepening : (int -> 'a list) -> int -> 'a list = <fun>
val show_string : string -> string = <fun>
val show_int : int -> string = <fun>
val show_char : char -> string = <fun>
val show_bool : bool -> string = <fun>
val print_option : ('a -> document) -> 'a option -> document = <fun>
val print_array : ('a -> document) -> 'a array -> document = <fun>
val list_trees_of_weight : int -> tree list = <fun>
val print_tree : tree -> document = <fun>
val show_tree : tree -> string = <fun>
val show_int_array : int array -> string = <fun>
Stack overflow during evaluation (looping recursion?).

Can you reproduce this?

Note: this issue is not related to ocaml-sf/learn-ocaml#305 (as the latter issue deals with learn-ocaml's CLI build, with another exercise).

List.hd and List.tl for "An Implementation of List with an Efficient Concatenation"

It seems that for the exercise "An Implementation of List with an Efficient Concatenation" we can just implement the functions hd and tl this way:

let hd cl =
  try Some (List.hd (to_list cl))
  with _ -> None;;

let tl cl =
  try Some (of_list (List.tl (to_list cl)))
  with Failure _ -> None;;

Maybe List.hd and List.tl should be disallowed?
Is it really an accepted answer or souldn't we try to implement something with a full pattern matching over the variant type?

a link to my first-year exercises (not very polished)

I recently finished the first iteration of my first-year, first-semester Learn-OCaml course.
I just uploaded the exercises that I wrote for the occasion to
https://github.com/gasche/paris8-corpus-2019.

The exercises are in French, although I would be happy to translate them if relevant/useful to someone.

The graders are not very good in several places, in particular as I did not know at the time how to test anything else than structural equality with the solution. (In particular, for exercises specified to accept results in arbitrary order, my graders force the same order as my solution.) I would like to revisit this from the advice in ocaml-sf/learn-ocaml#343, but I am not sure of when to do it.

Unbound type variables in constraints

I've been working through the excellent new OCaml exercises and noticed a lot of instances of unbound type variables in constraints as in this example taken from the "Enumerating Trees" exercise:

let product (enum1 : 'a enum) (enum2 : 'b enum) : ('a * 'b) enum =
  (* TO DO: Complete this definition. *)
  raise TODO

These are something of a personal dislike of mine, as I find they lead students into false reasoning about constraints + polymorphism. This could be re-written to use an explicitly-polymorphic constraint, with or without locally-abstract types:

let product : 'a 'b. 'a enum -> 'b enum -> ('a * 'b) enum =
  fun enum1 enum2 ->
    (* TO DO: Complete this definition. *)
    raise TODO

let product : type a b. a enum -> b enum -> (a * b) enum =
  fun enum1 enum2 ->
    (* TO DO: Complete this definition. *)
    raise TODO

which sadly loses the direct coupling of parameters to types but does at least enforce a polymorphic definition.

Perhaps changes of this sort could be applied throughout the course? I'm happy to make a PR myself, but would appreciate a general nod of approval first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.