<ggole>
Good to hear that it's on the way though :)
<ggole>
Also, thanks for addressing the idle-timer thing
<rks`>
don't thank me, thank lehy :p
Neros has joined #ocaml
* ggole
does so
<flux>
I like the error reporting :)
<flux>
but apparently it doesn't know if that (say) Common refers to common.ml in current directory unless I also open that file
<ggole>
That should work afaik: you may have to tell it a few things with a .merlin file before it will be happy
<ggole>
You also need to produce .cmt files for some features (iirc, cross-module location info).
<companion_cube>
it's very useful
<ggole>
With -bin-annot
ollehar has joined #ocaml
<flux>
thanks, enabled it, I shall follow how it works with that
talzeus has joined #ocaml
erlnoob has joined #ocaml
<rks`>
flux: merlin knows about other modules (for typing, completion, etc) as long as cmi files are available.
<rks`>
(and yes, for the "locate" command you need cmt files)
Arsenik has joined #ocaml
peterbb has quit [Ping timeout: 252 seconds]
iZsh has quit [Excess Flood]
iZsh has joined #ocaml
Drup has joined #ocaml
Yoric has joined #ocaml
weie has joined #ocaml
weie has quit [Client Quit]
weie has joined #ocaml
ollehar has quit [Ping timeout: 264 seconds]
Yoric has quit [Ping timeout: 260 seconds]
peterbb has joined #ocaml
talzeus has quit [Remote host closed the connection]
nikki93 has joined #ocaml
nikki93 has quit [Ping timeout: 265 seconds]
Arsenik has quit [Read error: Operation timed out]
dsheets_ has joined #ocaml
erlnoob has quit [Quit: erlnoob]
Anarchos has joined #ocaml
ulfdoz has joined #ocaml
manizzle has quit [Ping timeout: 264 seconds]
weie has quit [Quit: Leaving...]
ollehar has joined #ocaml
erlnoob has joined #ocaml
mort___ has joined #ocaml
chrisdotcode has joined #ocaml
f[x] has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
ulfdoz_ is now known as ulfdoz
jbrown has quit [Ping timeout: 245 seconds]
jbrown has joined #ocaml
<ggole>
There's no way to pass an explicit value as the option underlying an optional argument, is there?
nikki93 has joined #ocaml
<adrien>
I don't understand
<jpdeplaix>
ggole: you mean « f ?arg:None » ?
nikki93 has quit [Ping timeout: 240 seconds]
<ggole>
Optional arguments are option values under the hood.
<Drup>
ggole: use ? instead of ~
<ggole>
No, the argument is already optional. But I want to pass the option *myself*.
<Drup>
yes, try using ? instead of ~
<ggole>
Oh, hmm? Let me try that.
<ggole>
Aha
<ggole>
Thanks Drup :)
<Drup>
:]
<ggole>
I really should have thought of trying that.
jbrown has quit [Ping timeout: 245 seconds]
mort___ has quit [Quit: Leaving.]
mort___ has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 252 seconds]
ulfdoz_ is now known as ulfdoz
cesar_ has joined #ocaml
cesar_ is now known as Guest86287
Kakadu has quit [Quit: Konversation terminated!]
weie has joined #ocaml
weie has quit [Client Quit]
contempt has quit [Ping timeout: 240 seconds]
contempt has joined #ocaml
yezariaely1 has joined #ocaml
mangaba_leitosa has joined #ocaml
Yoric has joined #ocaml
iZsh has quit [Quit: Coyote finally caught me]
Yoric has quit [Ping timeout: 252 seconds]
rwmjones has quit [Ping timeout: 248 seconds]
Kakadu has joined #ocaml
erlnoob has quit [Quit: erlnoob]
rwmjones has joined #ocaml
ng_ has joined #ocaml
mort___ has quit [Quit: Leaving.]
<ng_>
Well, I had this code in another week, and today came back to add the hash table and big int. But the hash table is going wrong values, why?The first code is normal with the right values, and the second is adapted.
Kakadu has quit [Remote host closed the connection]
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
Yoric has joined #ocaml
iZsh has joined #ocaml
<companion_cube>
ng_: might be because of how big ints work?
Yoric has quit [Ping timeout: 245 seconds]
<companion_cube>
I'm not sure, but you may want to specialize Hashtbl for bigints
<companion_cube>
like module BigInTbl = Hashtbl.Make(struct type t = big_int let equal = big_int_equal let hash = .... end)
<companion_cube>
something like this
<companion_cube>
so that you are sure keys are compared properly
<ggole>
= will actually die with an exception on a big int
<ng_>
did not work :(
<companion_cube>
ng_: I mean, you need to use the hashtable then, if it's not clear from what I said
<companion_cube>
are you sure your algorithm is correct?
<ng_>
yap, the algorithm in the first code gives the right values,
<ng_>
only gives wrong with the table
<companion_cube>
err, why are you always looking for the same value in the table?
<ng_>
it will look in table the value n, if not find it computes
<companion_cube>
but why use a hashtable for a single value? :)
<yezariaely1>
companion_cube: sounds more like an application of "lazy" to me if the computation is complex.
<companion_cube>
yes indeed
<ggole>
It seems you are trying to memoize
<ggole>
Usually you'd do that on a combination of parameters, not a global
<ng_>
companion_cube, because I only have this value n :/
<companion_cube>
ng_: then I'd suggest you use Lazy
<ng_>
what is this?
<bernardofpc>
moreover, what happens if you use (s f 29 39) with n = 100 ?
<bernardofpc>
suppose n is on the table
<bernardofpc>
this is not the value you want
<bernardofpc>
the value you store with n is (s f 0 n), so you should only ask on the hashtable for this one, not for something that does not depend on ini _end
<ng_>
bernardofpc, if i put this, appears :" Fatal error: exception Stack_overflow!
<bernardofpc>
(sure, because your function recurses too much)
<bernardofpc>
(and is not tail-recursively written in any way)
<ng_>
so, what can i do?
<bernardofpc>
well, probably, this is an exercise, right ?
<bernardofpc>
so this will "never be asked"
<ng_>
bernardofpc, yap
<bernardofpc>
otherwise, you should learn many things
<ng_>
:)
<bernardofpc>
for example, how to make your factorial function tail-call
<bernardofpc>
second, how to calculate combinations without doing the factorials
<companion_cube>
tail-call is not mandatory though, but you definitively have a bug in the way you use the table
<bernardofpc>
sure
<ng_>
but without changing anything, this should work, but I can not find the error, because the function in any way that do will be very recursive
peterbb has quit [Ping timeout: 246 seconds]
yezariaely1 has quit [Quit: Leaving.]
lamawithonel_ has quit [Read error: Connection reset by peer]
<Kakadu_>
gour: Any luck with Qt?
qzmp has joined #ocaml
<gour>
Kakadu_: can't say...didn't have any free time for it...not even for python-web stuff
Guest86287 has quit [Remote host closed the connection]
cesar_ has joined #ocaml
cesar_ is now known as Guest21812
f[x] has quit [Ping timeout: 272 seconds]
Guest21812 has quit [Remote host closed the connection]
<qzmp>
Hi! I have a following problem to solve: Write a function, which takes a list of integers and splits it into two lists, one containing numbers less, and the other greater than 0. I wonder how to solve problem of returning two lists from function. I figured out a solution of taking 3 arguments: list of numbers and two empty list, here it is: http://pastebin.com/kAvHRTBN . Is there and can you tell me a solution, were two empty list woudn't
<mrvn>
qzmp: # List.partition;;
<mrvn>
- : ('a -> bool) -> 'a list -> 'a list * 'a list = <fun>
<mrvn>
qzmp: If you have a solution that takes 2 extra empty lists then make a wrapper function that adds them
<qzmp>
mrvn: oh, it's actually a homework, i think i can't use function from standard library which will do all work for me :)
<ggole>
A better way to write that is to have a nested function perform the loop
<ggole>
That way you don't have the two unwanted arguments
<ggole>
It's also clearer and more efficient to use matching instead of List.hd and List.tl
<mrvn>
List.hd and List.tl are totaly wrong there
<qzmp>
I have, just started learning ocaml, i haven't covered matches yet
<mrvn>
ggole: 'let foo arg = let rec loop ... in loop arg extras' vs. 'let rec foo arg extra = ... let foo arg = foo arg extra'
<mrvn>
qzmp: I think that exercise is for you to learn about matches
<ggole>
mrvn: those are equivalent? I'd personally lean towards the former.
<mrvn>
ggole: the later uses less indent
Kakadu_ has quit [Ping timeout: 272 seconds]
<qzmp>
for me also version with loop seems more cleaner, that's good point
<nicoo>
qzmp: You want to use a loop to iterate aver a list, instead of recursion ?
<nicoo>
o_O
<Drup>
qzmp: what's wrong with your solution, according to you ?
<qzmp>
i mean to have two functions to do loops
<nicoo>
Ah, I see
<qzmp>
Drup: this two extra arguments(empty lists) makes me feel strange :)
Yoric has joined #ocaml
<Drup>
qzmp: it's a regular technique, you can just wrap your function inside another one that feed it with empty lists
<qzmp>
ok, i see, i'm just not used to ocaml yet
<bernardofpc>
this is a very common thing with recursive functions
<Drup>
considering your knowledge, your solution is perfectly fine.
<nicoo>
qzmp: Basically, you need extra recursion variables (accumulators) to hold intermediate results. You can just hide them afterwards by wrapping in another function, or shadowing the definition (like mrvn told you) ; there is little difference between these solutions.
<bernardofpc>
the classic example is suming the values of a list
<bernardofpc>
you could write " let sum list = if list = [] then 0 else (List.hd list) + sum (List.tl list) "
<nicoo>
bernardofpc: I'm not sure we should trouble him with tail-recursion yet
<bernardofpc>
his trouble is that this version is t-r
<nicoo>
and s/let/let rec/ ;)
<qzmp>
nicoo: that's fine, i've already did tail-recursion
<nicoo>
'kay :)
<bernardofpc>
whereas the natural (for most people, I guess, starting to learn programming, and even old math people) is to write f(n+1) = g(f(n), ...)
<bernardofpc>
and then, you learn that you have to do t-r, then your function becomes f(n+1, acc) = f(n, h(acc, ...))
<bernardofpc>
(roughly)
<bernardofpc>
so you get one argument more to "invert" the position of g and f in the "natural" (IMO) recursive definition
<bernardofpc>
sometimes, the variant with accumulators (the "standard" name for these extra args) is simpler to come, especially when there are many of them
darkf has joined #ocaml
ggole has quit []
ng_ has quit [Quit: Leaving]
nikki93 has joined #ocaml
<technomancy>
opam seems very focused on getting the latest version of any given package; how do you tell it you need a specific version for your project?
<technomancy>
oh, I see the pin command
<technomancy>
weird that it's not mentioned more prominently; I would have thought everyone would have learned from the mistakes of rubygems not to be sloppy about dependencies
<technomancy>
it seems like `opam pin ...` does two completely different things; pinning to a version makes sense, but I can't tell what pinning to a path does.
k4nar has joined #ocaml
<Drup>
technomancy: pin is just "use this <thing> to get sources files"
<Drup>
<thing> can be a version in the opam repository, a directory in the file system, a http address or a vcs
cesar_ has joined #ocaml
cesar_ is now known as Guest61711
tane has joined #ocaml
<technomancy>
Drup: so if it's a directory it would be basically a local repository to use?
<technomancy>
makes sense
<Drup>
yes
<Drup>
I use it when testing than my patch don't break any other packages, it's quite useful
<technomancy>
would you use it with a set of git submodules in order to lock versions of your dependencies that way?
<Drup>
I don't use git submodules, tbh, I don't even know how to use them
tane has quit [Quit: Verlassend]
<technomancy>
they're a bit weird
wwilly has joined #ocaml
boogie has joined #ocaml
<technomancy>
it's just that typically you don't want users pulling down whatever happens to be the latest version of your dependencies; you want to run with a known-compatible set
<technomancy>
so it's kind of unsettling that you have to go out of your way to pin stuff
tane has joined #ocaml
<technomancy>
debian gets away with "always pull the latest" because they have an army of packagers who can hop on any breakage immediately and roll it back or fix it, but most package managers don't have that luxury =)
<wwilly>
hi
<Drup>
technomancy: hum, just to correct you, debian gets away by beeing 3 years outdated and by modifying heavily packages, that's not a sane model to adopt anyway.
<technomancy>
Drup: well right; it forces you to choose between stability and freshness. it works well for end users but is a poor model for stuff you're actively hacking on
boogie has quit [Remote host closed the connection]
<technomancy>
I expect eventually opam will move to being explicit by default, but hopefully it can happen in a more graceful way than it did with rubygems+bundler
boogie has joined #ocaml
<Drup>
why would you want to be explicit by defaut ? it's just a burden if you don't want to and you can do it if you really ned
<technomancy>
saying you're happy with any future version of a library is equivalent to saying you expect that library to never introduce any breaking changes
<technomancy>
it's completely unrealistic
<Drup>
then add version constraint to your package
<Drup>
and you will end up with a very nice cabal hell
<technomancy>
better cabal hell than rubygems hell =\
<Drup>
I disagree.
<technomancy>
I've spent the last four years maintaining a package manager that defaults to explicit versions; it's not difficult to avoid the problems of cabal.
wwilly has quit [Quit: This computer has gone to sleep]
qzmp has quit [Quit: Page closed]
wwilly has joined #ocaml
nikki93 has quit [Remote host closed the connection]
jbrown has joined #ocaml
yacks has joined #ocaml
Kakadu_ has joined #ocaml
lamawithonel_ has joined #ocaml
Guest61711 has quit [Remote host closed the connection]
Kakadu_ has quit []
pdewacht has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
chrisdotcode has quit [Read error: Connection reset by peer]
peterbb has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-280704]: i've been blurred!]
nikki93 has joined #ocaml
gour has quit [Quit: WeeChat 0.4.1]
ulfdoz has quit [Ping timeout: 246 seconds]
wwilly has quit [Quit: This computer has gone to sleep]
mfp has quit [Ping timeout: 245 seconds]
ollehar has quit [Ping timeout: 264 seconds]
tane has quit [Quit: Verlassend]
caligula has joined #ocaml
nikki93 has quit [Remote host closed the connection]