ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
rgrinberg has joined #ocaml
Arsenik has quit [Remote host closed the connection]
thomasga has quit [Quit: Leaving.]
thomasga has joined #ocaml
travisbrady has joined #ocaml
seanmcl has joined #ocaml
diethyl has joined #ocaml
madroach has quit [Ping timeout: 250 seconds]
madroach has joined #ocaml
NoNNaN has quit [Remote host closed the connection]
NoNNaN has joined #ocaml
travisbrady has quit [Quit: travisbrady]
srcerer has quit [Ping timeout: 245 seconds]
srcerer has joined #ocaml
srcerer has quit [Excess Flood]
thomasga has quit [Quit: Leaving.]
srcerer has joined #ocaml
jasdfkj has joined #ocaml
jasdfkj has quit [Remote host closed the connection]
jonludlam has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
travisbrady has joined #ocaml
eyyub has quit [Ping timeout: 258 seconds]
manud has joined #ocaml
michipili1 has left #ocaml [#ocaml]
rgrinberg has joined #ocaml
antinomy has quit [Ping timeout: 272 seconds]
jao has quit [Ping timeout: 250 seconds]
antinomy has joined #ocaml
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
waneck has quit [Read error: Connection reset by peer]
rgrinberg has quit [Quit: Leaving.]
seanmcl has joined #ocaml
travisbrady has quit [Quit: travisbrady]
rgrinberg has joined #ocaml
rgrinberg has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
manud has quit [Quit: Be back later ...]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
manud has joined #ocaml
waneck has joined #ocaml
boogie has quit [Remote host closed the connection]
seanmcl has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 244 seconds]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
travisbrady has joined #ocaml
boogie has joined #ocaml
boogie has quit [Remote host closed the connection]
darkf has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
travisbrady has quit [Quit: travisbrady]
antinomy has quit [Ping timeout: 258 seconds]
dmiles_afk has quit [Quit: Read error: 110 (Connection timed out)]
marynate has joined #ocaml
rgrinberg has joined #ocaml
BitPuffin has quit [Ping timeout: 250 seconds]
q66 has quit [Quit: Leaving]
rgrinberg has quit [Quit: Leaving.]
travisbrady has joined #ocaml
boogie has joined #ocaml
psy_ has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
boogie has quit [Ping timeout: 255 seconds]
q66 has joined #ocaml
travisbrady has quit [Quit: travisbrady]
whitequark has quit [Quit: Changing server]
whitequark has joined #ocaml
Submarine has joined #ocaml
Submarine has joined #ocaml
AlexRussia has joined #ocaml
q66 has quit [Quit: Leaving]
travisbrady has joined #ocaml
lordkryss has quit [Quit: Connection closed for inactivity]
travisbrady has quit [Quit: travisbrady]
struktured has joined #ocaml
manud has quit [Quit: Be back later ...]
JokerDoom has joined #ocaml
_JokerDoom has quit [Ping timeout: 260 seconds]
_JokerDoom has joined #ocaml
struktured has quit [Ping timeout: 258 seconds]
JokerDoom has quit [Ping timeout: 265 seconds]
boogie has joined #ocaml
boogie has quit [Ping timeout: 244 seconds]
ggole has joined #ocaml
chinglish has joined #ocaml
psy_ has joined #ocaml
manud has joined #ocaml
samrat has joined #ocaml
dmiles_afk has joined #ocaml
manud has quit [Ping timeout: 265 seconds]
<dmbaturin> Does utop sometimes eat some of whitespace for anyone else but me?
<dmbaturin> * When pasting code into it.
rgrinberg has quit [Quit: Leaving.]
boogie has joined #ocaml
elfring has joined #ocaml
boogie has quit [Ping timeout: 250 seconds]
rgrinberg has joined #ocaml
ygrek has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
manud has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
MercurialAlchemi has joined #ocaml
manud has quit [Quit: Be back later ...]
samrat has joined #ocaml
cojy has quit [Read error: Connection reset by peer]
cojy has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
boogie has joined #ocaml
leifw has quit [Ping timeout: 258 seconds]
lopex has quit [Ping timeout: 272 seconds]
emmanueloga has quit [Ping timeout: 258 seconds]
samrat has quit [Ping timeout: 240 seconds]
boogie has quit [Ping timeout: 245 seconds]
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
lopex has joined #ocaml
leifw has joined #ocaml
emmanueloga has joined #ocaml
ygrek has joined #ocaml
manud has joined #ocaml
psy_ has quit [Ping timeout: 252 seconds]
slash^ has joined #ocaml
bobpoekert has quit [Ping timeout: 258 seconds]
S11001001 has quit [Ping timeout: 264 seconds]
__marius______ has quit [Ping timeout: 272 seconds]
jcloud has quit [Ping timeout: 255 seconds]
jeroud has quit [Ping timeout: 272 seconds]
andreypopp_ has quit [Ping timeout: 272 seconds]
davine has joined #ocaml
davine has left #ocaml [#ocaml]
rgrinberg has quit [Quit: Leaving.]
lopex has quit [Ping timeout: 258 seconds]
nox has quit [Ping timeout: 258 seconds]
dch has quit [Ping timeout: 258 seconds]
emmanueloga has quit [Ping timeout: 272 seconds]
leifw has quit [Ping timeout: 260 seconds]
dch has joined #ocaml
nox_ has joined #ocaml
leifw has joined #ocaml
lopex has joined #ocaml
girrig has quit [Ping timeout: 256 seconds]
girrig has joined #ocaml
boogie has joined #ocaml
emmanueloga has joined #ocaml
boogie has quit [Ping timeout: 256 seconds]
MercurialAlchemi has quit [Ping timeout: 244 seconds]
jonludlam has quit [Ping timeout: 244 seconds]
ygrek has quit [Ping timeout: 256 seconds]
Arsenik has joined #ocaml
thomasga has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 255 seconds]
slash^1 has joined #ocaml
slash^ has quit [Ping timeout: 272 seconds]
psy_ has joined #ocaml
manud has quit [Quit: Be back later ...]
koderok has joined #ocaml
koderok has quit [Remote host closed the connection]
lopex has quit [Quit: Connection closed for inactivity]
milosn has quit [Ping timeout: 264 seconds]
manud has joined #ocaml
samrat has joined #ocaml
manud has quit [Client Quit]
Simn has joined #ocaml
slash^1 has left #ocaml [#ocaml]
marynate has quit [Quit: Leaving]
<ggole> Sigh, inability to abstract code over constructors leads directly to copy+paste.
kakadu_ has joined #ocaml
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 258 seconds]
darkf has joined #ocaml
darkf_ has quit [Ping timeout: 258 seconds]
samrat has quit [Quit: Computer has gone to sleep.]
boogie has joined #ocaml
eyyub has joined #ocaml
boogie has quit [Ping timeout: 265 seconds]
slash^ has joined #ocaml
oscar_toro has joined #ocaml
kandu has quit [Ping timeout: 244 seconds]
chambart has joined #ocaml
milosn has joined #ocaml
antinomy has joined #ocaml
ikaros has joined #ocaml
michipili has joined #ocaml
testcocoon has quit [Quit: Coyote finally caught me]
<michipili> Notice to FreeBSD OCaml-lers: ports for OCaml-4.02.1, Labltk and Camlp4 are ready, you can get them on my github if you want to try them before they are merged into ports: https://github.com/michipili/ports-bsd/tree/ocaml-4.02.1
<michipili> Have a nice Sunday! :)
<Leonidas> arch linux got 4.02.1 yesterday
<Leonidas> took them quite some while, considering other stuff is usually packaged the same day it is released
testcocoon has joined #ocaml
<kakadu_> Let's say I have global C++ object and I want to monitor when properties of this object are changed. When they are I want to send ocaml-react signals. It seems I need ocaml thread which will monitor for changes and raise signals. What do you think about this approach, will it work?
<michipili> Leonidas: The build system of OCaml is terrible and not that good written. Now that camlp4 and labltk are standalone packages, this a kind of triple trouble! :)
jeroud has joined #ocaml
pgomes has joined #ocaml
<michipili> I am considering writing the build system again, using https://github.com/michipili/bsdowl but I need to write version 3.0, have it in Debian, *BSD and MacPorts, and then there are chances to come up with something better.
rand000 has joined #ocaml
boogie has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
slash^ has joined #ocaml
boogie has quit [Ping timeout: 255 seconds]
andreypopp_ has joined #ocaml
jonludlam has joined #ocaml
eyyub1 has joined #ocaml
eyyub has quit [Ping timeout: 240 seconds]
__marius______ has joined #ocaml
eyyub2 has joined #ocaml
eyyub1 has quit [Ping timeout: 245 seconds]
dch has quit [Remote host closed the connection]
emmanueloga has quit [Remote host closed the connection]
nox_ has quit [Remote host closed the connection]
leifw has quit [Remote host closed the connection]
<whitequark> come on, the ocaml buildsystem is not that bad
eyyub2 has quit [Ping timeout: 244 seconds]
jcloud has joined #ocaml
<michipili> whitequark: Well… every time I have to port the latest version of OCaml to FreeBSD I discover new breakages and failures… I might agree on “not that bad” but not on better.
S11001001 has joined #ocaml
<michipili> whitequark: BTW I am starting to work on port of ppx_deriving.
samrat has joined #ocaml
antinomy has quit [Ping timeout: 258 seconds]
boogie has joined #ocaml
boogie has quit [Ping timeout: 265 seconds]
dch has joined #ocaml
AlexRussia has quit [Ping timeout: 250 seconds]
AlexRussia has joined #ocaml
<whitequark> michipili: oooh that's really great to hear
<michipili> Wait until I see the build system :D :D
<michipili> (just joking, obivously)
<whitequark> ocamlbuild
<michipili> BTW I have a small issue with github
<whitequark> (in the rare case where I want a bsd I use openbsd, but it's still great to hear)
<michipili> Do you know anything about commit 094a852 ?
bobpoekert has joined #ocaml
<whitequark> in which project?
nox_ has joined #ocaml
<michipili> Some part of GitHub seems to think that v1.0 is ca5d62d some other part that it is 094a852
<michipili> In deriving.
<whitequark> mmm
<whitequark> 094a852 does not exist
<michipili> FreeBSD builds a download URL like https://codeload.github.com/whitequark/ppx_deriving/legacy.tar.gz/v1.0?dummy=/deriving-1.0.tar.gz
<whitequark> legacy.tar.gz?
<michipili> Well, I don't know the details, it looks like it's an API allowing to download any tag as a tarball.
<whitequark> looks like you're using a legacy API, which is probably confused by force pushes
<michipili> Why not? It is not supposed to make a difference, and it makes it easier to prepare a -devel port, tracking latests developments.
<whitequark> huh?
<whitequark> how is the URL you posted makes it easier than the URL I just provided?
andreypopp_ has quit [Ping timeout: 244 seconds]
jeroud has quit [Ping timeout: 244 seconds]
<michipili> This is because the URL is built by the ports framework, but it can refer to really any commit, not just a tag.
<whitequark> it works with any git ref
antinomy has joined #ocaml
<michipili> True!
jcloud has quit [Ping timeout: 244 seconds]
bobpoekert has quit [Ping timeout: 272 seconds]
S11001001 has quit [Ping timeout: 265 seconds]
__marius______ has quit [Ping timeout: 265 seconds]
<whitequark> also, the port really should be called ppx_deriving
<whitequark> deriving is an unrelated legacy project
Thooms has joined #ocaml
<michipili> Okay!
<michipili> I take good note of this.
nox_ has quit [Read error: Connection reset by peer]
eyyub2 has joined #ocaml
dch has quit [Ping timeout: 260 seconds]
BitPuffin has joined #ocaml
ygrek has joined #ocaml
boogie has joined #ocaml
boogie has quit [Ping timeout: 264 seconds]
samrat has quit [Ping timeout: 244 seconds]
Unhammer has quit [Remote host closed the connection]
manizzle has joined #ocaml
jgjl has joined #ocaml
<michipili> whitequark: The build system croaks
<michipili> + ocamlfind ocamlc -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving.cmi src/ppx_deriving.mli
<michipili> ocamlc: unknown option `-safe-string'.
<michipili> usage: ocamlfind ocamlc [options] file
<michipili> ocamlc knows about -safe-string
<michipili> so I guess ocamlfind intercepts the flag…
<michipili> Any clue?
<michipili> ocamlfind ocamlc -version says 4.02.1
<michipili> Which version of ocamlfind do you use to build? I have 1.5.5 which looks to be the latest one.
<ggole> Use -passopt, I think
dch has joined #ocaml
<ggole> Although hmm, ocamlfind ocamlc -safe-string doesn't barf for me
nox__ has joined #ocaml
jeroud has joined #ocaml
<nicoo> michipili: Which version of findlib (ocamlfind) do you have?
samrat has joined #ocaml
andreypopp_ has joined #ocaml
samrat has quit [Ping timeout: 260 seconds]
leifw has joined #ocaml
samrat has joined #ocaml
__marius______ has joined #ocaml
<whitequark> yep, you need at least 1.5.4 for ppx_deriving to work at all
<whitequark> michipili: ^
emmanueloga has joined #ocaml
lopex has joined #ocaml
chambart has quit [Ping timeout: 250 seconds]
boogie has joined #ocaml
thomasga has quit [Quit: Leaving.]
boogie has quit [Ping timeout: 245 seconds]
rfv has quit [Ping timeout: 255 seconds]
seanmcl has joined #ocaml
thomasga has joined #ocaml
rfv has joined #ocaml
xavierm02 has joined #ocaml
jcloud has joined #ocaml
<xavierm02> Hi. When I try to pin llvm to 3.1 using opam, it gets stuck on "cp ~/.opam/system/lib/llvm/META.llvm ~/.opam/system/lib/llvm/META" and my fans start spinning but the ~/.opam/system/lib/llvm directory doesn't even seem to exist. Any hints on how to avoid that? Thank you in advance for your answers.
S11001001 has joined #ocaml
<whitequark> it compiles for quite some time and the command that it shows does not indicate what actually happens right now
<whitequark> so, wait.
Reventlov has quit [Quit: leaving]
Reventlov has joined #ocaml
lopex has quit [Ping timeout: 252 seconds]
samrat has quit [Ping timeout: 265 seconds]
<xavierm02> okay, I'll try that. Thanks :)
AlexRussia has quit [Ping timeout: 264 seconds]
dav has joined #ocaml
lopex has joined #ocaml
bobpoekert has joined #ocaml
milosn has quit [Ping timeout: 264 seconds]
q66 has joined #ocaml
<michipili> ocaml is 4.02.1 and fimdlib 1.5.5
<michipili> So it is very strange, or?
AlexRussia has joined #ocaml
<whitequark> wrong findlib version
<whitequark> I mean, you have 1.5.5, but you also have old findlib somewhere
<whitequark> that's the only explanation I can think of
elfring has quit [Quit: Konversation terminated!]
thomasga has quit [Quit: Leaving.]
samrat has joined #ocaml
boogie has joined #ocaml
slash^1 has joined #ocaml
boogie has quit [Ping timeout: 264 seconds]
slash^ has quit [Ping timeout: 272 seconds]
mawuli has quit [Ping timeout: 258 seconds]
samrat has quit [Ping timeout: 240 seconds]
struktured has joined #ocaml
samrat has joined #ocaml
chambart has joined #ocaml
darkf has quit [Quit: Leaving]
pgomes has quit [Ping timeout: 250 seconds]
chambart has quit [Ping timeout: 264 seconds]
xavierm02 has quit [Quit: Page closed]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
boogie has joined #ocaml
dav has quit [Read error: No route to host]
boogie has quit [Ping timeout: 258 seconds]
struktured has quit [Ping timeout: 258 seconds]
jcloud has quit [Quit: Connection closed for inactivity]
ikaros has quit [Quit: Ex-Chat]
daftluck has joined #ocaml
thomasga has joined #ocaml
pgomes has joined #ocaml
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ikaros has joined #ocaml
struktured has joined #ocaml
pgomes has quit [Quit: Leaving]
Thooms has quit [Quit: WeeChat 1.0.1]
lordkryss has joined #ocaml
tharugrim has quit [Ping timeout: 272 seconds]
tharugrim has joined #ocaml
boogie has joined #ocaml
demonimin has quit [Ping timeout: 260 seconds]
MercurialAlchemi has joined #ocaml
boogie has quit [Ping timeout: 245 seconds]
demonimin has joined #ocaml
<struktured> does the row ordering in _tags correspond to the ordering observed by ocamlbuild?
<whitequark> sorta, but I don't know if it's intended or accidental
Hannibal_Smith has joined #ocaml
<struktured> got it
boogie has joined #ocaml
slash^1 has quit [Read error: Connection reset by peer]
Hannibal_Smith has quit [Ping timeout: 244 seconds]
<Drup> whitequark: this oasis thing about empty library is annoying.
<Drup> exposing the mapper doesn't even solve the problem, since you still have the ppx package that is ""empty""
jgjl has joined #ocaml
chambart has joined #ocaml
dsheets has joined #ocaml
oriba has joined #ocaml
boogie has quit [Remote host closed the connection]
dsheets has quit [Ping timeout: 264 seconds]
dsheets has joined #ocaml
Thooms has joined #ocaml
<struktured> if you intend on some library being a shared internal lib among other libs in an oasis project, should it probably be a parent library?
<companion_cube> I don't think so
<struktured> I was just adding it as a dep to my build depends instead
<struktured> companion_cube: your containres project, in fact, uses a parent for says, the containers_* packages.
<companion_cube> sure
<companion_cube> but it's not a "shared internal lib", if I understood your situation
dsheets has quit [Ping timeout: 256 seconds]
<struktured> in your case the parent is a public core library and the others are optional extensions which also depend on the parent, it seems.
arj has joined #ocaml
samrat has quit [Ping timeout: 256 seconds]
<companion_cube> yes
<companion_cube> I don't think I have a project with a standalone internal library
<struktured> companion_cube: yeah in my case mine isn't really either. its just not all that useful by itself.
<companion_cube> with oasis you have InternalModules in library sections
<struktured> companion_cube: still is a separate library, whether public or not. but thanks for reminding me of that was looking for it this morning in fact for my "Something_intf" module
<companion_cube> don't you want to expose Foo_intf modules as well?
<struktured> sorry, I think I meant the intern version.
<companion_cube> oh, ok
<struktured> while I have your intention, I noticed opam doesn't install your bench mark thingy. is there a way to enable that using opam ?
<struktured> *attention
demonimin has quit [Remote host closed the connection]
<companion_cube> oh, I don't know, I don't consider benchmarks should be installed :/
<struktured> you don't recommend it you mean?
<companion_cube> it's more "git clone" then compile and run benchmarks
<companion_cube> I don't mark them as installable in my projects
<struktured> ok
milosn has joined #ocaml
eyyub2 has quit [Ping timeout: 255 seconds]
demonimin has joined #ocaml
eyyub2 has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
boogie has joined #ocaml
demonimin has quit [Remote host closed the connection]
waneck has quit [Remote host closed the connection]
dsheets_ has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
demonimin has joined #ocaml
Hannibal_Smith has joined #ocaml
chambart has quit [Ping timeout: 264 seconds]
slash^ has joined #ocaml
demonimin has quit [Remote host closed the connection]
Thooms has quit [Quit: WeeChat 1.0.1]
Thooms has joined #ocaml
chambart has joined #ocaml
rgrinberg has joined #ocaml
araujo has quit [Quit: Leaving]
samrat has joined #ocaml
demonimin has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
jcloud has joined #ocaml
davine has joined #ocaml
struktured has quit [Ping timeout: 264 seconds]
rgrinberg has quit [Quit: Leaving.]
dsheets_ has quit [Ping timeout: 255 seconds]
dsheets_ has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
davine has quit [Ping timeout: 265 seconds]
slash^ has quit [Read error: Connection reset by peer]
__JokerDoom has joined #ocaml
chambart has quit [Read error: Connection reset by peer]
chambart has joined #ocaml
_JokerDoom has quit [Ping timeout: 245 seconds]
rand000 has quit [Ping timeout: 264 seconds]
chambart has quit [Read error: Connection reset by peer]
demonimin has quit [Remote host closed the connection]
dmiles has joined #ocaml
dmiles_afk has quit [Ping timeout: 264 seconds]
demonimin has joined #ocaml
dsheets_ has quit [Ping timeout: 245 seconds]
dsheets_ has joined #ocaml
ggole has quit []
oriba_ has joined #ocaml
chambart has joined #ocaml
struktured has joined #ocaml
chinglish has quit [Quit: Nettalk6 - www.ntalk.de]
oriba has quit [Ping timeout: 245 seconds]
rand000 has joined #ocaml
chambart has quit [Ping timeout: 245 seconds]
davine has joined #ocaml
davine has left #ocaml [#ocaml]
dav has joined #ocaml
rand000 has quit [Ping timeout: 255 seconds]
araujo has joined #ocaml
chambart has joined #ocaml
<michipili> whiteshark: I can build it, but how to install?
<michipili> whitequark: ^
<michipili> :)
Submarine has quit [Remote host closed the connection]
dsheets_ has quit [Ping timeout: 245 seconds]
dsheets_ has joined #ocaml
seanmcl has joined #ocaml
rand000 has joined #ocaml
milosn has quit [Ping timeout: 245 seconds]
demonimin has quit [Remote host closed the connection]
t4nk387 has joined #ocaml
chambart has quit [Read error: Connection reset by peer]
<t4nk387> Hello :)
chambart has joined #ocaml
demonimin has joined #ocaml
<t4nk387> How would I find the most frequently occurring element in a list without using recursive functions? Only the List module
<companion_cube> I don't think List provides this
<t4nk387> Nah it doesnt
<t4nk387> I assume we have to sort the list first
<t4nk387> But im stuck as to where to go from there
<companion_cube> maybe it means you have to use List.fold_left
<t4nk387> Yeah
<t4nk387> Im thinking, given a list like [1;1;1;2;2;3;3;3;3;4], run a function that returns [(1, 3); (2, 2); (3, 4); (4, 1)]
<t4nk387> Which is easy, with recursive functions
<t4nk387> how would I achieve this with folding/mapping?
<t4nk387> or is this the wrong way of thinking about this problem
chambart has quit [Ping timeout: 245 seconds]
<t4nk387> Anyone else?
<kakadu_> you can use fold and list of pairs in accumulator
<kakadu_> List.assoc and some other functions will help you to store counts in acc
<t4nk387> Hmm
<t4nk387> Im not totally sure how fold work
<t4nk387> Do you give it a list, a function and an initial acc
<t4nk387> fold [1;2;3;4;5] (+) 0 = 1+2+3+4+5 = 15
<t4nk387> is that right?
<t4nk387> it returns the accumulator
<kakadu_> нуз
milosn has joined #ocaml
<kakadu_> yep
<t4nk387> ok so
<t4nk387> I assume the acc in this case is an empty list []
<companion_cube> you can simulate a direct recursion on a list with List.fold_left
<t4nk387> And it needs to add to this acc a pair if x in (x, y) = the current element else find (x, y) with x = current element and add 1 to y
<companion_cube> the accumulator hre could indeed be the mapping element->arity
<t4nk387> So if I can write this problem using rec, I can always translate my recursive function to a fold_left?
<kakadu_> In general, I think no
Hannibal_Smith has quit [Ping timeout: 240 seconds]
<t4nk387> ah ok
<companion_cube> if it's a recursive function that examines the elements one by one, left-to-right
<t4nk387> So if I can write a recrsive function that does it
<t4nk387> or does something
<t4nk387> how do I translate that to fold?
<t4nk387> let rec add ls = match ls with |[] -> 0 | x :: xs -> x+add(xs);;
<t4nk387> thats the same as
<t4nk387> fold ls (+) 0
<kakadu_> 1stly you can make 'add' tail-recursive
<t4nk387> So the base case is the initial value of the acc
<t4nk387> Oh yeah I know
__JokerDoom has quit [Ping timeout: 264 seconds]
ikaros has quit [Quit: Ex-Chat]
kakadu_ has quit [Quit: Page closed]
demonimin has quit [Remote host closed the connection]
<t4nk387> Sois this correct
<t4nk387> Any recursive function of the form: |[] -> | hd :: tl ->
<t4nk387> can be make into fold.left
<t4nk387> made*
demonimin has joined #ocaml
<daftluck> As I understand it, fold_left just applies a function to elements in a list and accumulates the value as it goes.
<companion_cube> I think so, if the function is tailrec on tl
<daftluck> If your recursive function does that, it should be equivalent.
<daftluck> By definition.
<t4nk387> im going to write a function
<t4nk387> then seeif i can transfer it :P
JokerDoom has joined #ocaml
arj has quit [Quit: Leaving.]
dmiles has quit [Ping timeout: 255 seconds]
rgrinberg has joined #ocaml
<rgrinberg> hello!
michipili1 has joined #ocaml
<companion_cube> world
<rgrinberg> :)
michipili has quit [Ping timeout: 250 seconds]
<rgrinberg> companion_cube: what are you your christmas hacking plans?
JokerDoom has quit [Ping timeout: 245 seconds]
<companion_cube> going to some place where I won't have access to the internet, most likely :)
<companion_cube> what about you?
<rgrinberg> believe it or not i find myself a lot more productive hacking wise without internet
<rgrinberg> :D
Thooms has quit [Quit: WeeChat 1.0.1]
MercurialAlchemi has quit [Ping timeout: 272 seconds]
<companion_cube> heh. I'll be with my family or girlfriend so hacking may not be my priority :p
<rgrinberg> i'll go somewhere warmer (maybe cuba) a little later. January perhaps
dsheets_ has quit [Ping timeout: 252 seconds]
<rgrinberg> save some money that way
JokerDoom has joined #ocaml
<rgrinberg> in the meantime, I'd love to push re to work for ocsigenserver :/
demonimin has quit [Read error: Connection reset by peer]
<companion_cube> ocsigenserver doesn'twork with Re?
<rgrinberg> nah it uses some strange wrapper around pcre
<rgrinberg> the wrapper itself can be ported verbatim as long as our pcre support is good enough
<Drup> (through ocamlnet ...)
<companion_cube> oh dear
<companion_cube> what's missing from Re ?
<Drup> yeah
<rgrinberg> some basic stuff from Pcre
<rgrinberg> like full_split
<companion_cube> heh!
<rgrinberg> would be easy to implement that on top of your work
<companion_cube> but it's up to Vouillon to decide whether to include that
<rgrinberg> :/
<companion_cube> it's in the PR now
<Drup> companion_cube: we can ping him again tomorrow =')
demonimin has joined #ocaml
<companion_cube> :D
<companion_cube> please do.
<rgrinberg> avsm can merge stuff in re as well
<companion_cube> but Re needs some love about unicode as well
<rgrinberg> probably ok for trivial stuff
<companion_cube> the interface Re.split_full is slightly different from PCRE though
demonimin has quit [Remote host closed the connection]
<Drup> rgrinberg: don't worry, we will make him review =')
<rgrinberg> yeah it's a simple difference however. just flatten the substrings into the adt pcre expects
<companion_cube> I didn't even thought of it, but Re_pcre already contains such functions
<rgrinberg> companion_cube: like what?
<companion_cube> Re_pcre.split
<companion_cube> otoh it's nice to be able to return iterators, I think
<rgrinberg> Re_pcre.split? where do you see that?
demonimin has joined #ocaml
thomasga has quit [Quit: Leaving.]
<companion_cube> in utop
michipili1 has left #ocaml [#ocaml]
<rgrinberg> utop is lying :D
<t4nk387> Hey again
<t4nk387> I found this code online, which works, and I think I understand it
<t4nk387> But how would I do this with list.fold?
<t4nk387> instead of recursion
<rgrinberg> t4nk387: homework?
<companion_cube> meh. I don't know oO
<t4nk387> yeah :/
<companion_cube> anyway
<t4nk387> As soon as our prof said "rec" was not allowed, I went home and cried
<t4nk387> :P
<daftluck> But higher-order functions are nice!
<t4nk387> Plus, this is the very last assignment
<t4nk387> before christmas
<t4nk387> I have done all the rest and would really like to get this done
<t4nk387> But im stumped
<t4nk387> :(
<daftluck> It's refreshing to hear someone miss recursion, though. Most people in my class would probably cheer.
<companion_cube> before christmas ← no "rec" allowed!
<t4nk387> haha :D
<t4nk387> ...
<t4nk387> before the holidays*
<rgrinberg> t4nk387: do you think you understand fold? can you write List.map or List.filter in terms of it?
_JokerDoom has joined #ocaml
<t4nk387> I understand Map a lot more
<t4nk387> I think I understand fold
<Drup> daftluck: show them https://xkcd.com/1270/
<t4nk387> It goes through each element, updating an accumulator as it goes
<companion_cube> map is easier than fold
<rgrinberg> t4nk387: try writing map in terms of fold
<companion_cube> once you get fold, you're ready ^^
<daftluck> Drup: XD, it's perfect.
JokerDoom has quit [Ping timeout: 265 seconds]
<daftluck> Love the alt text.
<daftluck> I certainly felt that way when I tried to learn some Haskell years ago. OCaml gave me trouble too, until I got some Scheme and Emacs Lisp exposure.
demonimin has quit [Ping timeout: 260 seconds]
demonimin_ has joined #ocaml
JokerDoom has joined #ocaml
_JokerDoom has quit [Ping timeout: 265 seconds]
jbalint has joined #ocaml
jbalnit has left #ocaml [#ocaml]
<t4nk387> rgrinberg: Would it be something like this let rec map f list = List.fold_left f [] list;;
<t4nk387> actually with no rec
<t4nk387> let map f list = List.fold_left f [] list;;
<rgrinberg> t4nk387: that's a first step :) write a working map in terms of fold and then a recursive one
<rgrinberg> hint: you will need to tweak the f in List.fold_left f
<t4nk387> How does this help me in turning a recursive function into a fold?
<t4nk387> :P
JokerDoom has quit [Ping timeout: 265 seconds]
<t4nk387> And I thought so :P
<rgrinberg> write map both ways and you will see that the translation is almost mechanical
<t4nk387> what data type is + - / *
<t4nk387> ?
<t4nk387> I dont think i understand the data type inputted into fold :P
<t4nk387> Its not a function I dont think
<t4nk387> as (+) isnt a function, but you can do List.fold_left List.fold_left (+) 0 [1;2;3;4;5];;
<t4nk387> oops
<t4nk387> but yeah
<rgrinberg> (+) is most definitely a function
<t4nk387> Oh
<t4nk387> Hang on I think I see
JokerDoom has joined #ocaml
demonimin_ has quit [Remote host closed the connection]
<t4nk387> I need to get the head of the list, apply the function to it and @ it to the acc
<t4nk387> return the acc
<t4nk387> thats what map is, right?
<rgrinberg> something like that :)
<rgrinberg> you can cons rather than concat though
<t4nk387> yeah yeah
<t4nk387> i get why let map f list = List.fold_left f [] list;; isnt working
<t4nk387> but dont know how to fix it
<t4nk387> You need a cons somewhere
<t4nk387> As you said, its a problem with the f
<t4nk387> as the acc and list are correct
demonimin has joined #ocaml
<rgrinberg> well, try writing f
<t4nk387> i did a simple (funx -> x+1)
<t4nk387> fun x*
<rgrinberg> first of all, how many arguments f should take?
myyst has quit [Ping timeout: 264 seconds]
<t4nk387> 1
<t4nk387> wait
<t4nk387> is it 1?
<t4nk387> as (+) isnt 1
<rgrinberg> ask the top level
<t4nk387> : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a = <fun>
rgrinberg has quit [Read error: Connection reset by peer]
rgrinberg1 has joined #ocaml
<t4nk387> 2
<t4nk387> 2 arguments
<t4nk387> of diffrent datatypes
<t4nk387> return a value of the first argument
<t4nk387> data type
<rgrinberg1> can you describe the 2 arguments?
<t4nk387> They both have diffrent data types
<t4nk387> However, a value is returned that has the first arguments data type
<rgrinberg1> the first argument: the accumulator
<t4nk387> ah
<rgrinberg1> the 2nd argument: the current element of the list
<t4nk387> So in our case
<t4nk387> our first argument needs to be a
<t4nk387> list?
<rgrinberg1> yep. in our case the accumlator is a list
<rgrinberg1> since that's what we are returning
dmiles_afk has joined #ocaml
<rgrinberg1> in your code:
<rgrinberg1> List.fold_left f [] list
<rgrinberg1> [] <— and the first argument of f are of the same type
<rgrinberg1> so
<rgrinberg1> List.fold_left (fun acc x -> … ) [] list
<rgrinberg1> if acc is 'a list, x is 'a
<t4nk387> map (fun x y -> (y+1) :: x) [1;2;3;4;5];;
<t4nk387> I see
<rgrinberg1> why map?
<rgrinberg1> fold
<rgrinberg1> also you don't need any + to write map
<t4nk387> I know
<t4nk387> aha!
<t4nk387> map (fun x y -> x @ [y+1]) [1;2;3;4;5];;
<t4nk387> Ok that works
<t4nk387> Now, List.map only takes a function that takes 1 argumnt
<t4nk387> This one takes 2 to work
<t4nk387> let map f list = List.fold_left f [] list;;
<t4nk387> map (fun x y -> x @ [y+1]) [1;2;3;4;5];; = [2;3;4;5;6]
<t4nk387> so how do we make the left side's function only take 1 argument?
<t4nk387> :)
rand000 has quit [Quit: leaving]
_JokerDoom has joined #ocaml
<rgrinberg1> first of all, you dont need 2 definitions
<rgrinberg1> let map f list = List.fold_left (fun x y -> x @ [y]) [] list;;
<rgrinberg1> this is looking much better
<rgrinberg1> however something needs to be done with this f parameter
<t4nk387> But where do you use f on the right hand side?
<rgrinberg1> that's what im asking you
<rgrinberg1> :D
<t4nk387> (fun x y -> x @ [y]) |> f
<t4nk387> or
<t4nk387> f |> (fun x y -> x @ [y])
<t4nk387> haha xD
girrig has quit [Ping timeout: 250 seconds]
<t4nk387> I hate fold :P rec is so much easier xD
dsheets_ has joined #ocaml
__JokerDoom has joined #ocaml
JokerDoom has quit [Ping timeout: 244 seconds]
<companion_cube> nah, fold_left is nice
<t4nk387> Im sure when I get wtf is going on, ill use it more then rec
JokerDoom has joined #ocaml
_JokerDoom has quit [Ping timeout: 255 seconds]
girrig has joined #ocaml
Simn has quit [Quit: Leaving]
__JokerDoom has quit [Ping timeout: 244 seconds]
Submarine has joined #ocaml
_JokerDoom has joined #ocaml
<t4nk387> AHA
<t4nk387> let map f list = List.fold_left (fun x y -> x @ [f y]) [] list;;
<t4nk387> I thought
<companion_cube> looks like it
<companion_cube> test it on an example
<t4nk387> If we are adding [y] to the list, surley we should be adding y after the function
<companion_cube> rgrinberg1: could you review my PR? maybe that would help Vouillon ^^
<companion_cube> t4nk387: the types agree
<t4nk387> yeah it works :P
__JokerDoom has joined #ocaml
<rgrinberg1> companion_cube: which pR?
<companion_cube> on Re
<t4nk387> So now back to the original question, How would I find the most frequent element in a sorted list
<t4nk387> using fold and/or map
<rgrinberg1> companion_cube: https://github.com/ocaml/ocaml-re/pull/36 this one?
JokerDoom has quit [Ping timeout: 265 seconds]
<companion_cube> 1/ compute a mapping element->number of occurrences (with fold)
__JokerDoom has quit [Read error: Connection reset by peer]
<companion_cube> 2/ find the maximum in this mapping (fold)
<companion_cube> yep ^^
<t4nk387> I dont think we can use the Map module
<companion_cube> if you want to of course, rgrinberg1
__JokerDoom has joined #ocaml
<companion_cube> t4nk387: association list
<rgrinberg1> companion_cube: I've reviewed it apart from the newest commits
<rgrinberg1> let me do that now
<t4nk387> Never used them before, or been tought them
<t4nk387> Any tips? :P
<companion_cube> they're ('a * 'b) list
<t4nk387> Thought so
<companion_cube> where 'a is the type of keys, 'b the type of values
<companion_cube> look at List.assooc
<t4nk387> Something like tht nayway
<companion_cube> assoc*
<t4nk387> assoc a l returns the value associated with key a in the list of pairs l. That is, assoc a [ ...; (a,b); ...] = b if (a,b) is the leftmost binding of a in list l. Raise Not_found if there is no value associated with a in the list l.
_JokerDoom has quit [Ping timeout: 264 seconds]
<t4nk387> so thats for search a list like that
<t4nk387> that makes sence
<rgrinberg1> companion_cube: teh list is sorted i believe you can do it in 1 pass
<t4nk387> How would you actually make a list like that in the first place? Or increase the value of one of the keys
<companion_cube> you need auxiliary functions
<t4nk387> cant use rec though
<t4nk387> :/
<t4nk387> oh
<t4nk387> could I use fold for this?
demonimin has quit [Ping timeout: 260 seconds]
<t4nk387> for the auxiliary function?
demonimin has joined #ocaml
<rgrinberg1> t4nk387: you wrote an explicitly recursive solution right?
<companion_cube> t4nk387: probably :p
<t4nk387> Well
<t4nk387> It was taken from somewhere online, I tried to make sense of it in my head xD
<rgrinberg1> well if you can't write it without fold chances of writing with a fold are slim :/
<t4nk387> But what do you think will be easier? Translating that into fold or writing my own assoation lists useing fold?
<t4nk387> Yeah
<companion_cube> can't you use the function in List that already do association lists?
<t4nk387> Ok, ill try wring a function that adds 1 to an association lists value
<t4nk387> Then try and put it into fold
<t4nk387> Thanks for the help btw
oriba_ has quit [Ping timeout: 245 seconds]
<companion_cube> you're welcome
demonimin has quit [Remote host closed the connection]
araujo has quit [Quit: Leaving]
<t4nk387> Okie Dokie!
<t4nk387> Easy
<t4nk387> Now to put it into fold?
lordkryss has quit [Quit: Connection closed for inactivity]
<t4nk387> yeah that works
demonimin has joined #ocaml
<t4nk387> and I think its tail recursive as well?
JokerDoom has joined #ocaml
__JokerDoom has quit [Ping timeout: 260 seconds]
<t4nk387> Is this possible to do using fold?
<rgrinberg1> t4nk387: show your original solutio
<rgrinberg1> again
<rgrinberg1> i meant the original solution you found online
<t4nk387> oh ok
<rgrinberg1> do you understand it?
<t4nk387> a little
<rgrinberg1> btw you can drop the sorting it does
<rgrinberg1> since your list is already sorted
<t4nk387> thought so
<rgrinberg1> can you explain me the purpose of the params in loop?
<t4nk387> to keep track of the variables
<rgrinberg1> in more detail
<t4nk387> like how far its got through the list
<rgrinberg1> what's the purpose of every var
<rgrinberg1> maxelt, maxcount, elt, count
<t4nk387> count is how many of one variable its found
<t4nk387> Then maxcount is like the maxium number
<t4nk387> of the count
<t4nk387> Same with element
<t4nk387> So say it counts 3 of ele1 and 4 of ele2
<t4nk387> count would be 3 first, so would maxcount
<rgrinberg1> what's maxelt and elt?
JokerDoom has quit [Ping timeout: 244 seconds]
<t4nk387> elt would be ele1 and maxelt would be ele1 also
<t4nk387> on the next pass
<t4nk387> or next element
<t4nk387> count is 4
<t4nk387> which is more then maxcount
<t4nk387> so maxcount is set to 4
<rgrinberg1> ok so you understand that solution?
<t4nk387> yeah
<t4nk387> I dont know what "compare" means
<rgrinberg1> ok so here's a protip
<rgrinberg1> you dont need compare
<rgrinberg1> since your list is sorted
<rgrinberg1> in your explicit recursion solution
<t4nk387> its just match list with
<t4nk387> ?
<rgrinberg1> yep
<t4nk387> ? :)
<rgrinberg1> yeah
<t4nk387> nice
<t4nk387> right
<rgrinberg1> when accumulating with explicit recursion you store your accumulated values in the params of your function
<rgrinberg1> loop in this case
<t4nk387> yep i see
JokerDoom has joined #ocaml
<rgrinberg1> fold will pass around the accumulated value for you
<rgrinberg1> as long as its 1 var
manizzle has quit [Ping timeout: 244 seconds]
<t4nk387> right
<rgrinberg1> i.e. tuple them up
<rgrinberg1> List.fold_left (fun (maxelt, maxcount, elt, count) x -> … ) …
<t4nk387> maxelt, maxcount, elt, count?
<t4nk387> ah yeah
<t4nk387> now on the right hand side of the arrow
<t4nk387> I need the
<t4nk387> x :: xs -->
<t4nk387> bit
<rgrinberg1> you already have the x
<t4nk387> Yeah
<rgrinberg1> you dont need the xs
<t4nk387> I mean on the righthand side of the arrow
<rgrinberg1> the whole point of fold is that it will go over the list for you
<t4nk387> I ment on the right hand side of fun (maxelt, maxcount, elt, count) x -> … should be the right hand side of x::xs -> in the original rec function
rgrinberg1 has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
Arsenik has quit [Remote host closed the connection]
oscar_toro has quit [Ping timeout: 250 seconds]
JokerDoom has quit [Ping timeout: 272 seconds]
<t4nk387> Am I anywhere near right?
<t4nk387> xD
<t4nk387> Left out a comma in line 3 btw
<t4nk387> there we go