Skip to content

Commit

Permalink
Fix for recent ocaml (immutable strings)
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr authored and yurug committed Sep 15, 2021
1 parent 7dcf4d7 commit 5323b7d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions exercises/mooc/week6/seq1/ex2/test.ml
Expand Up @@ -33,14 +33,14 @@ let exercise_2 =
[%ty: string -> char Code.MultiSet.t] "letters" letters [])

let permut s =
let s = String.copy s in
for i = String.length s - 1 downto 2 do
let s = Bytes.of_string s in
for i = Bytes.length s - 1 downto 2 do
let j = Random.int (i+1) in
let x = s.[i] in
s.[i] <- s.[j] ;
s.[j] <- x
let x = Bytes.get s i in
Bytes.set s i (Bytes.get s j) ;
Bytes.set s j x
done ;
s
Bytes.to_string s

let exercise_3 =
set_progress "Grading exercise 3." ;
Expand Down

0 comments on commit 5323b7d

Please sign in to comment.