adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
UndefinedIsNotAF has joined #ocaml
spew has quit [Quit: Connection closed for inactivity]
Haudegen has quit [Ping timeout: 240 seconds]
rgherdt has quit [Ping timeout: 245 seconds]
seliopou has quit [Quit: whaaaat]
oni-on-ion has quit [Ping timeout: 250 seconds]
seliopou has joined #ocaml
c4rc4s has quit [Remote host closed the connection]
seliopou has quit [Client Quit]
seliopou has joined #ocaml
c4rc4s has joined #ocaml
ravenousmoose has joined #ocaml
ravenousmoose has quit [Ping timeout: 276 seconds]
seliopou has quit [Quit: whaaaat]
seliopou has joined #ocaml
seliopou has quit [Quit: whaaaat]
seliopou has joined #ocaml
seliopou has quit [Quit: whaaaat]
seliopou has joined #ocaml
EmeraldMoon has joined #ocaml
c4rc4s has quit [Read error: Connection reset by peer]
c4rc4s has joined #ocaml
EmeraldMoon has quit [Remote host closed the connection]
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
mfp has quit [Ping timeout: 265 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 246 seconds]
tormen_ has joined #ocaml
tormen has quit [Ping timeout: 264 seconds]
logicmoo has quit [Ping timeout: 245 seconds]
brettgilio has joined #ocaml
_whitelogger has joined #ocaml
dmiles has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
jao has joined #ocaml
zolk3ri has quit [Ping timeout: 260 seconds]
gravicappa has joined #ocaml
zolk3ri has joined #ocaml
EmeraldMoon has joined #ocaml
EmeraldMoon has quit [Remote host closed the connection]
_whitelogger has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
jao has quit [Ping timeout: 240 seconds]
vicfred has quit [Quit: Leaving]
brettgilio has quit [Ping timeout: 245 seconds]
narimiran has joined #ocaml
gravicappa has quit [Ping timeout: 265 seconds]
_whitelogger has joined #ocaml
okuu has joined #ocaml
unyu has quit [Ping timeout: 276 seconds]
pyx has joined #ocaml
pyx has quit [Client Quit]
okuu has quit [Quit: ERC (IRC client for Emacs 26.3)]
unyu has joined #ocaml
gravicappa has joined #ocaml
ggole has joined #ocaml
ravenousmoose has joined #ocaml
rgherdt has joined #ocaml
Serpent7776 has joined #ocaml
ohama has quit [Ping timeout: 240 seconds]
Nahra has joined #ocaml
Nahra has joined #ocaml
Nahra has quit [Changing host]
ohama has joined #ocaml
gravicappa has quit [Ping timeout: 268 seconds]
jaar has joined #ocaml
FreeBirdLjj has joined #ocaml
tane has joined #ocaml
_whitelogger has joined #ocaml
Haudegen has joined #ocaml
jaar has quit [Ping timeout: 252 seconds]
tizoc has quit [Quit: Coyote finally caught me]
tizoc has joined #ocaml
UndefinedIsNotAF has quit [Ping timeout: 240 seconds]
mfp has joined #ocaml
gravicappa has joined #ocaml
<narimiran> how can i do something similar to this python code: `for a, b, c, d in zip(line, line[1:], line[2:], line[3:])`? is there a way to iterate/fold in parallel on multiple (more than 2) lists/strings at once?
<Leonidas> narimiran: there is map2
<Leonidas> but there is not general n-ary map or zip, because try to express the signature of that.
<narimiran> i know, that's why explicitly said "more than 2" ;)
<Leonidas> what would the signature of such a thing look like?
<narimiran> yeah, i see your point
<narimiran> so, is there some way around it? how would you achieve the same as the python code posted?
<Leonidas> You can build map4 just fine
<narimiran> write your own map4?
<Leonidas> that's one way
<Leonidas> though I am not sure whether it is the best
<Leonidas> depends on what you actually want to do
<narimiran> this is the task: https://adventofcode.com/2016/day/7
<narimiran> and here is Peter Norvig's: https://nbviewer.jupyter.org/url/norvig.com/ipython/Advent of Code.ipynb#Day-7:-Internet-Protocol-Version-7
<tane> narimiran, given that you have a list of characters, you can match more than one, e.g. a::b::c::d::t when a = d && b = c && a <> b ->
<Leonidas> I would probably parse out the [] first and then get a list of all 4 character sequences, overlapping and then filter.
<narimiran> tane: nice, that might be the way to go!
<tane> are you warming up for the next AoC? :)
<narimiran> tane: that's exactly what i'm doing :)
<narimiran> i decided to solve this year's AoC in ocaml (previously i have done it in python and nim), so now i'm trying to get familiar with ocaml before december :)
<tane> nice
<narimiran> i'm posting my AoC 2017 solutions here: https://github.com/narimiran/AdventOfCode2017 — so if any of you have some spare time to give me some advice what to change and how to improve my ocaml solutions, i'd be grateful
<ggole> n-ary map/zip/etc are nicely typable, although not in OCaml's type system. eg, typed Racket supports such variadic types.
Serpent7776 has quit [Read error: Connection reset by peer]
Serpent7776 has joined #ocaml
<octachron> Even in Ocaml, it is possible to get quite close with tuple as GADT-enhanced list, but not with the standard tuple kind (because the type system has no idea that _ * _ and _ * _ * _ are related)
retropikzel has quit [Quit: Leaving]
silver has joined #ocaml
Nahra has quit [Quit: leaving]
<Leonidas> (* LANGUAGE TupleKinds *) *ducks*
<def`> It is possible to make an lightweight nary map in OCaml
<def`> Type errors are not user-friendly (not C++ level, but not nice)
<def`> # nary_map [[1;2;3]] string_of_int
<def`> # nary_map [[1;2;3]; ["foo"; "bar"; "baz"]] (fun i s-> string_of_int i ^ s)
<def`> and they have the expected runtime semantics
<def`> this combines GADTs, constructor disambiguation and custom list syntax.
retropikzel has joined #ocaml
<def`> (for a naive implementation, it is possible to get reasonably efficient ones but that's tricky :O)
zolk3ri has joined #ocaml
<narimiran> tane: your idea for pattern matching worked like a charm!
<narimiran> now i need to check if some sublist of list `a` (which matches a given pattern) is also sublist of list `b`. i'm thinking of using `CCList.sublists_of_len` (https://c-cube.github.io/ocaml-containers/dev/containers/CCList/index.html#val-sublists_of_len), don't know if there's a more idiomatic solution?
FreeBirdLjj has quit [Remote host closed the connection]
<def`> what do you mean by sublist matching a given pattern?
<def`> Are you using dune exec to measure the runtime?
<narimiran> i'm usually using `perf stat` to measure it
<def`> perf stat ./mybinary?
<def`> Your measurements make it look like the ocamlruntime takes around ~50 ms to initialize.
<narimiran> yep, it is always something like that
<def`> it should take around ~1-2ms
FreeBirdLjj has joined #ocaml
<narimiran> is there a way to measure the correct time with `perf`, or should i just subtract some constant in my head (like i currenty do :))?
<def`> I think there is :). If you can show me the script you use I can tell you how to fix it.
<narimiran> `perf stat -r 100 -d dune exec ./ocaml/day07.exe > /dev/null`
<def`> ah indeed.
<def`> So you are measuring dune incremental build times :)
<narimiran> `perf stat -r 100 -d ./_build/default/ocaml/day07.exe > /dev/null` is this better?
<narimiran> it seems that it is :)
<def`> also, you can add --profile release to build with optimizations
<def`> dune build --profile release ...bla...
<narimiran> no need to manually pass -O2 and similar stuff?
<narimiran> do i need to specify something for that `release` build in my `dune` file?
<def`> no need.
<def`> the dune file normally works for developement and release mode
<def`> It defaults to development mode, I don't know how to change that
<def`> Ah, you can put (profile release) in dune-workspace file apparently
<narimiran> ok, i'll try and see if it makes any difference
leah2 has quit [Ping timeout: 250 seconds]
<narimiran> i only have `dune` and `dune-project` files
<def`> you can create the dune-workspace one. It is optional
leah2 has joined #ocaml
<narimiran> can i check if some flag was indeed used? (i'd like to check if dune automatically picked up this release mode)
<def`> you can check _build/log file
<narimiran> there is still only `_build/default`. i would have expected to have `_build/release` now too, but ok
<narimiran> def`: thanks for the tips, now ocaml shines in the full light: https://github.com/narimiran/AdventOfCode2017/commit/714cab92c7769c83ac3eee8ec8f1681f35e8d2a9
<def`> cool :)
kakadu has joined #ocaml
florest has joined #ocaml
oni-on-ion has joined #ocaml
jao has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
<rgrinberg> narimiran: the direcctory structure for dune is _build/{context_name}, but as def` said, you may default to whatever profile you want in a context.
<narimiran> rgrinberg: ah, i see, thanks!
ziyourenxiang has quit [Ping timeout: 268 seconds]
bartholin has quit [Ping timeout: 276 seconds]
bartholin has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
nullifidian has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
jnavila has joined #ocaml
ravenousmoose has joined #ocaml
retropikzel has quit [Quit: Leaving]
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
hashbjorn has quit [Quit: ZNC - http://znc.in]
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
bitwinery has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
ggole has quit [Quit: Leaving]
jao has quit [Remote host closed the connection]
jao has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ravenousmoose has joined #ocaml
ravenousmoose has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
florest has quit [Remote host closed the connection]
profan has quit [Remote host closed the connection]
jao has quit [Remote host closed the connection]
gravicappa has quit [Ping timeout: 268 seconds]
narimiran has quit [Quit: Leaving]
jao has joined #ocaml
jao is now known as Guest56162
Jesin has quit [Quit: Leaving]
Jesin has joined #ocaml
Serpent7776 has quit [Quit: Lost terminal]
ziyourenxiang has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
kakadu has quit [Remote host closed the connection]
tane has quit [Quit: Leaving]