<hcarty>
Not the prettiest. And if no suitable value is found, raising the last raised exception may not be appropriate.
<thelema>
let with_first f l = List.enum l |> map (Result.catch f) |> Enum.find Option.is_some |> Option.get
<thelema>
raises Not_found if all fail
<hcarty>
It's missing a cast from Restult -> Option, but it looks workable beyond that
<hcarty>
s/Restult/Result/
<hcarty>
map (Result.catch f |- Result.to_option)
<thelema>
sure.
<thelema>
maybe a Result.catch_option would be useful
<thelema>
or the corresponding option functions on Result.t
<_habnabit>
Enum.filter_map identity |> Enum.get
sepp2k has joined #ocaml
<thelema>
_habnabit: wouldn't that raise the first exception from f?
<thelema>
oh, n/m
<_habnabit>
no, I mean after the ... okay
<thelema>
nice.
<thelema>
although it would compute more than necessary.
<thelema>
or not, since enum is lazy...
bwright has joined #ocaml
<hcarty>
That would return an option result, so it would come down to wanting 'a option or 'a
<thelema>
hcarty: no, filter_map unpacks the options
<hcarty>
thelema: Enum.get
<hcarty>
return 'a option
<thelema>
oh. silly me.
<thelema>
why don't we have an Enum.get_exn?
<hcarty>
I've wondered the same :-) Although apparently not enough to file a patch or bug report...
<thelema>
if only some brave soul would do so, we could be rescued from the tyrrany of the batteries maintainer... :)
<hcarty>
Down with Batteries! Long live Batteries AAA'!
<thelema>
lol
eikke has quit [Ping timeout: 244 seconds]
rby has quit [Quit: Lost terminal]
yezariaely has joined #ocaml
LittleEndian has joined #ocaml
LittleEndian is now known as BigEndian
BigEndian has left #ocaml []
CamelBack has joined #ocaml
<CamelBack>
hey all / bonsoir
oriba has joined #ocaml
<CamelBack>
may i speak french here ? i have a problem with arrays bidimentionals and 2 loop
sepp2k has quit [Ping timeout: 240 seconds]
<CamelBack>
Je souhaiterais ajouter l'entier 1 à tous les éléments d'un tableau, en utilisant 2 boucles FOR imbriquées (car mon objectif quand cela marchera sera de tester la validité d'un sudoku)
<CamelBack>
le meme algo fonctionne avec un int Array, mais pas avec un int Array Array
<CamelBack>
i will try to say it in english too ;)
jonludlam_home has quit [Remote host closed the connection]
<Kakadu>
Ohhh, translate.ru is cool
<thelema>
CamelBack: the problem is line 8
<companion_cube>
don't ask to ask, just ask
<CamelBack>
i woud like to add the integer (1) to all elements in a matrix, with 2 loops (when it will work my goal is to make an sudoku validity tester)
<CamelBack>
your proposition work fine, i dont understand why you say its better with 2 fun intricated
<CamelBack>
this work fine : let out = Array.init 3 (fun _ -> Array.make 3 0) in
<CamelBack>
i understand
<CamelBack>
is for to create an int array array with 2 coordonates, and insert inside ( 2;3;4 ); (5;6;7) ...
<thelema>
yes, you can directly build the result array without the nested loops
<CamelBack>
i understand
<CamelBack>
but i made a simple exemple because i cannot start with testing sudoku grid ;)
<CamelBack>
but with your help, i have solve my problem and my function to test if there 1 and 1 time only an numbers include (1 to 9) each collumn and line, work, thanks thelema ;)
fraggle_laptop has quit [Read error: Connection reset by peer]
Xizor has joined #ocaml
ttamttam has quit [Remote host closed the connection]
g0dmoney- has quit [Ping timeout: 255 seconds]
g0dmoney- has joined #ocaml
raichoo has joined #ocaml
jonludlam has quit [Ping timeout: 244 seconds]
Anarchos has joined #ocaml
yezariaely has quit [Quit: Leaving.]
jonludlam has joined #ocaml
CamelBack has quit [Quit: WeeChat 0.3.5]
sebz has joined #ocaml
milosn_ has quit [Read error: Connection reset by peer]
g0dmoney- has quit [Changing host]
g0dmoney- has joined #ocaml
albacker has joined #ocaml
milosn has joined #ocaml
raichoo has quit [Quit: Lost terminal]
Cyanure has quit [Ping timeout: 244 seconds]
Cyanure has joined #ocaml
<NaCl>
adrien: was there a Pcre slackbuild lying around?
edwin has quit [Remote host closed the connection]
dgbaley27 has joined #ocaml
<dgbaley27>
I've got a parser.mly that I'm using from someone else. When I user Parser, there are errors if the .mli exists. If I remove it, everything is fine. This has been ok for now using make because I just rm it manually after calling ocamlyacc. But I want to give ocamlbuild a try. Is there a way to automatically remove it or not generate using ocamlyacc/ocamlbuild
sebz has joined #ocaml
andreypopp has quit [Quit: Leaving.]
sepp2k has quit [Remote host closed the connection]
Xizor has quit []
Morphous has quit [Ping timeout: 240 seconds]
bwright has quit [Ping timeout: 240 seconds]
Morphous has joined #ocaml
bwright has joined #ocaml
roha has joined #ocaml
Cyanure has quit [Remote host closed the connection]
<oriba>
dgbaley27, you could just rm *.mli before compilation...?!
<oriba>
or... not *.mli but the yacc stuff
<dgbaley27>
But if I use ocamlbuild main.native, for example, it will automatically do everything, there's no hook for me to remove the parser.mli between the correct steps
<oriba>
hmhh I don't use ocamlbuild
<_habnabit>
dgbaley27, are you writing a .mli file? where is it coming from
<oriba>
with OCamlMakefile, if make fails, I would do make clean && make
<oriba>
ocamlyacc
<_habnabit>
dgbaley27, I don't know what you're doing, because ocamlyacc + ocamlbuild has never given me issues before
eikke has joined #ocaml
<dgbaley27>
ocamlyacc generates .ml and .mli from .mly
<dgbaley27>
The error has something to do with A.modl and A.expr in parser.mly
<_habnabit>
so, you kind of need to show us /the actual error/ and what you're doing to get it
dnolen has joined #ocaml
<dgbaley27>
File "parser.mli", line 89, characters 48-56:
<dgbaley27>
Error: Unbound type constructor modl
<dgbaley27>
i'll pastebin a test main I wrote for it, one moment
<dgbaley27>
Actually, that's not important, it was just a hello, world that didn't even use the parser. if I try to do "ocamlopt parser.mli" i get that error. If I try to use the parser module while the mli exists, it complains the there is no .cmi. If I just remove the .mli, I can use the parser module without a problem.
<_habnabit>
why are you running ocamlopt?
<dgbaley27>
ocamlc, it doesn't matter
<_habnabit>
why are you running /either/? you said you were using ocamlbuild
<dgbaley27>
I'm breaking down the step that fails.
<dgbaley27>
It's just a wrapper is it not?
<_habnabit>
okay, do `ocamlbuild -clean` and then `ocamlbuild -verbose 2 hello.byte` or whatever your .ml file is named
<_habnabit>
pastebin the output in your terminal and the contents of _build/_log