<ArthurStrong>
Hi all. Is there a standard function to slice a list by n-item parts? like [1;2;3;4;5;6] by 2-item sublists -> [1;2];[3;4];[5;6]
<ArthurStrong>
also, it is possible in utop to print (in debug mode) all function arguments during execution?
<ArthurStrong>
I want to debug a recursive function...
nullcone has quit [Quit: Connection closed for inactivity]
Haudegen has joined #ocaml
<haesbaert>
ArthurStrong: I think List.partition with an external ref counter is your smallest solution
raver has joined #ocaml
<haesbaert>
oh I misread, disregard me.
<ArthurStrong>
haesbaert: thanks for the idea
narimiran_ is now known as narimiran
mfp has joined #ocaml
<ArthurStrong>
I have an issue with List.iter
<ArthurStrong>
I just want to run a function for each element in list
<ArthurStrong>
but...
<ArthurStrong>
Error: This expression has type string list -> unit but an expression was expected of type 'a list
<ArthurStrong>
my function has signature string list -> unit, OK
<ArthurStrong>
but what List.iter wants?
<abc_>
This is List.iter's signature: 'a list -> f:('a -> unit) -> unit = <fun>
<ArthurStrong>
what should I do?
<abc_>
I don't know either, still learning it, and saw your question by accident.
<ArthurStrong>
oh I just supplied arguments in wrong order. neverming. thanks!
* ArthurStrong
noob
<schube[m]>
lubegasimon: assuming you're asking how OCaml infers that x has type (int, string) pair without you writing the type explicitly? The answer to that is that OCaml knows that "the key `first` belongs to type `('a, 'b) pair`", therefore when you use a literal which has this key it will infer that it is `('a, 'b) pair. If you define another record type with a key named `first` in the same module you may run into trouble because
<schube[m]>
OCaml will then infer that new record type so you should try to keep these keys unique within a module.
<abc_>
ArthurStrong: Congratulate!
<ArthurStrong>
(utop) anyway, is it possible to log all function arguments for debugging?
mbuf has quit [Quit: Leaving]
narimiran has quit [Ping timeout: 244 seconds]
ggole has joined #ocaml
dborisog has quit [Remote host closed the connection]
tane has joined #ocaml
andreas303 has quit [Remote host closed the connection]
andreas303 has joined #ocaml
dborisog has joined #ocaml
amiloradovsky has joined #ocaml
<ArthurStrong>
I'm trying to read a text fil
<ArthurStrong>
file
<ArthurStrong>
but getting: Error: The module In_channel is an alias for module Core_kernel__.Import.In_channel, which is missing
<ArthurStrong>
however, I do "open Core"
<ArthurStrong>
what is this?
<ArthurStrong>
"open Core_kernel" - no luck as well
<ArthurStrong>
let f = In_channel.read_lines "tmp";;
<ArthurStrong>
excuse me, but Ocaml's system of modules is just crappy. is there a standard set of them?
<ArthurStrong>
what should I use and what shouldn't?
dborisog has quit [Remote host closed the connection]
<ArthurStrong>
oh, I should "open Stdio"
ygrek has joined #ocaml
vesper11 has quit [Read error: Connection reset by peer]
vesper11 has joined #ocaml
<ArthurStrong>
Anyway. is there a guide on ocaml libraries? Standard, non-standard, batteries, etc?