<adrien>
I really don't like the code generated by sexplib (partly because it missed an obvious code factorization) but the functions to convert s-expressions to records are really annoying
<NihilistDandy>
Seeking pointers, no matter how oblique.
<NihilistDandy>
If you please
<NihilistDandy>
I have no idea what I'm having trouble putting my head around, but I've been beating my head on this for a while now.
<flux>
nihilistdandy, well, so your problem is iterating numbers from 1..x/2?
<NihilistDandy>
Right, it would appear so
<NihilistDandy>
Though I suppose the base case is (x/2), so it might be more that I need to iterate from x/2 .. 1
<NihilistDandy>
Well, x/2 .. 2, since 1 is irrelevant
<flux>
in that case you would call 2 the base case
<flux>
x/2 would be the first case
<flux>
let's choose 1 for this situation anyway
<flux>
so if we ever reach 1, the function should return false
<flux>
let rec ip y = if y = 1 then false
<NihilistDandy>
Okay, that makes sense
<flux>
however, that doesn't compile
<NihilistDandy>
Right, need the else
<flux>
so how would you write the division test?
<MaskRay_>
let is_prime x = let rec ip y = y = 1 || x mod y <> 0 && ip (y-1); in ip (x/2);;
<MaskRay_>
there's a bit fault
<flux>
hmm, wouldn't that return always true when y = 1?
<flux>
(but we don't call numbers divisible by 1 prime numbers ;))
<MaskRay_>
so i said `there's a bit fault'
<flux>
while you can use the shortcut operators there, perhaps it's more clear not to
<NihilistDandy>
I have been using those exact components for the last hour, and it completely escaped me to just use logical operators :/
<NihilistDandy>
I kept trying to pull some cute if then else nonsense
<flux>
:)
<flux>
well, let's say that we have if y = 1 then false else .. and we only need to fill in the .. part
<flux>
we need to return false, if the x is not divisible by y
<NihilistDandy>
So x mod y <> 0
<MaskRay_>
this should work: let is_prime x = let rec ip y = y<>0 && (y=1 || x mod y<>0 && ip (y-1)); in ip (x/2);;
<flux>
or, we could jump straight to the answer ;)
<MaskRay_>
we actually have some criteria on where a number n is prime or not
<MaskRay_>
these criteria are conjunctive
<NihilistDandy>
I appreciate both the efforts. I'm pretty heavily from the Haskell world, but my programming languages class is in OCaml. I've been rather out of sorts, it seems :D
<MaskRay_>
possible arguments passed to `ip' are 0,1,2..
<NihilistDandy>
It's an odd shift.
<MaskRay_>
obviously, we should make `ip 0' returns false, otherwise `is_prime 1 = true' (as flux said)
<NihilistDandy>
Quite
<MaskRay_>
and `ip 1' should be true (because 2,3 are primes)
<flux>
I think you could just as well use 1 as the base case, as you now handle both 0 and 1 specially
<flux>
while you don't take negative numbers into account :)
<flux>
or rather, perhaps the y = 0 -case could be handled outside 'ip'
<MaskRay_>
i couldn't if `ip' doesn't know other information about its argument
<flux>
but, all the same, perhaps it's more clear that the same test is performed to all numbers
<NihilistDandy>
flux: See, that would have been my preference, but the assignment calls for it to be done in the auxiliary. I would definitely have built the whole thing a bit differently :D
Kakadu has joined #ocaml
<NihilistDandy>
This is what's always pained me about functional programming… I hammer away at a problem for a while, and when I find or see a solution, it just becomes more stupefyingly obvious the more I look at it
<NihilistDandy>
It's a good pain :D
<NihilistDandy>
Thanks again, flux and MaskRay_. Clearly I am in need of coffee
<flux>
good luck with your studies :)
avsm has joined #ocaml
_andre has joined #ocaml
rby_ has quit [Ping timeout: 252 seconds]
rby has joined #ocaml
Tobu has quit [Ping timeout: 248 seconds]
ankit9 has quit [Ping timeout: 272 seconds]
ankit9 has joined #ocaml
Tobu has joined #ocaml
rby has quit [Ping timeout: 252 seconds]
iago has joined #ocaml
dsheets has quit [Quit: Leaving.]
everyonemines has quit [Quit: Leaving.]
Arsenik has joined #ocaml
<adrien>
bwah!
Cyanure has quit [Quit: Quitte]
Arsenik has quit [Quit: Quitte]
<adrien>
so, I had a syntax error when I was not using camlp4 on a file
Cyanure has joined #ocaml
<adrien>
the error was on this line: { metadata_of_sexp sexp with size_expanded = pkg_size }
<adrien>
File "makeypkg/makeypkg.ml", line 119, characters 21-25:
<adrien>
Error: Syntax error
<adrien>
the fix was to:
<adrien>
{ (metadata_of_sexp sexp) with size_expanded = pkg_size }
<adrien>
add parens
<adrien>
and my build times have dropped even lower now \o/
letrec has joined #ocaml
Cyanure has quit [Client Quit]
Cyanure has joined #ocaml
<adrien>
and writing my own to/from sexp conversion functions saved 20KB of code in the resulting executable
<flux>
..when does that matter?
iago has quit [Ping timeout: 245 seconds]
Vinnipeg has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
<adrien>
I think that sexplib _always_ depends on type-conv, i.e. there is no way to disable the syntax extension; can anyone confirm that before I dive into the code?
Vinnipeg has quit [Quit: Ухожу я от вас (xchat 2.4.5 или старше)]
Nihilist_ has joined #ocaml
NihilistDandy has quit [Disconnected by services]
Nihilist_ is now known as NihilistDandy
avsm has quit [Ping timeout: 244 seconds]
ousado has quit [Read error: Operation timed out]
ousado has joined #ocaml
yezariaely1 has joined #ocaml
yezariaely1 has quit [Client Quit]
ousado has quit [Changing host]
ousado has joined #ocaml
<adrien>
is there a (simple) tool to find unused code in a source tree?
rby has joined #ocaml
<yezariaely>
what does the notation `name stand for? definition of an element of the singleton type name?
<adrien>
yezariaely: can you give some more context? maybe an example?
<yezariaely>
this seems to be similar to erlang's atoms, isn't it?
<adrien>
as you've seen, it's a polymorphic variant; typically they should start with an uppercase letter just like variant but a bug in the parser has allowed lowercase for some time and keeping that is now considered backward compatibility
<adrien>
I don't know erlang's atoms however so I can't compare
Nihilist_ has joined #ocaml
<yezariaely>
adrien: maybe they are not that similar. In erlang, an atom is kind of an instance of a singleton type
NihilistDandy has quit [Disconnected by services]
<yezariaely>
What is polymorphic about them, here?
Nihilist_ is now known as NihilistDandy
<adrien>
you don't have to declare them and their names don't clash
<adrien>
type t = A | B
<adrien>
type u = B | C
<adrien>
these would "clash": you wouldn't be able to reference t's B variant
<adrien>
but you can: type t = [ `A | `B ] and type u = [ `B | `C ]
<adrien>
the compiler won't even wonder where "`B" is from
<adrien>
and you don't have to declare/define them before using them: let f = function | `A i -> i | `B f -> truncate f
metasyntax|work has joined #ocaml
<yezariaely>
adrien: thank you!
<adrien>
they have drawbacks though ;-)
<adrien>
mainly, their typing is more complex and can be confusing
<yezariaely>
adrien: the type inference is not more complex, isn't it?
iago has joined #ocaml
<adrien>
yezariaely: it can quite easily lead to errors that are harder to understand
<adrien>
is anyone using pfff? (the code parsing/analysis tool)
<adrien>
apparently it doesn't want to use my system installation of lablgtk2 and others when building
<yezariaely>
is there something similar in ocaml to haskell's $ operator?
<bnwr>
adrien: I used it once
<bnwr>
it worked fine
<thizanne>
yezariaely: no, but you can define it
<bnwr>
I can't install it right now though
<thizanne>
let ($) x = x
<thizanne>
be careful, the associativity is not the same
<thizanne>
in ocaml, f $ x1 $ x2 = (f x1) x2
<thizanne>
in haskell, it's f (x1 x2)
<adrien>
arf: it bundles files from ocaml itself, ocamldbd (what is it?), ocaml-cairo, ocamlgraph, lablgtk2 (and names it "ocamlgtk"), ocamlmpi, ocamlnet (a subset of it), ocaml-pcre, ocaml-thrift
<adrien>
pisses me off actually
<yezariaely>
thizanne: thank you!
<flux>
adrien, I'm pretty sure it doesn't piss of the targeted demography of that program, though :).
<flux>
adrien, I guess he'd like to bundle the ocaml compiler in as well, but that's be a bit over the top..
<adrien>
I did "make depend -j3" and then I had to run "git clean" to be able to do anything else (and without -j3)
<adrien>
and there are custom makefiles in the "deps" afaiu
<adrien>
it's definitely dirty
<adrien>
but I don't mind that it bundles everything but it shouldn't force using the extra libs
<adrien>
erf
<adrien>
s/extra/bundled/
<adrien>
what put me in a bad mood was: # Yes I know about autoconf ... and autoconf sux.
<adrien>
in the configure (perl) script
<adrien>
and the current configure script is definitely buggy
<_andre>
does anyone know the proper way to add "-ppopt -lwt-debug" to an ocamlbuild _tags file?
Drup has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
<f[x]>
_andre, you will have to write special rule in myocamlbuild.ml
<f[x]>
ocamlbuild doesn't know anything about ppopt out of the box
<_andre>
f[x]: do you know if there's anything in oasis that creates this rule?
Kakadu has quit [Quit: Page closed]
<f[x]>
_andre, afaik - no
<_andre>
ok
<_andre>
thanks
<f[x]>
currently oasis is weak with preprocessing
<f[x]>
just add after OASIS_END something like : flag ["ocaml"; "pp"; "ppopt_lwt_debug"] & S[A"-ppopt"; A "-lwt-debug"];
<f[x]>
and in _tags: "source.ml": ppopt_lwt_debug
Tobu has joined #ocaml
MaskRay_ has quit [Quit: leaving]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
cago has quit [Ping timeout: 265 seconds]
<_andre>
is there a way to make ocamlbuild not clear its output?
asdfhjkl has joined #ocaml
Cyanure has quit [Quit: Quitte]
<bnwr>
_andre: is -classic-display what you want?
<bnwr>
if not, explain your need more thouroughly
<_andre>
yes, that's it
<_andre>
thank you :)
wagle has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
letrec_ has joined #ocaml
letrec has quit [Ping timeout: 276 seconds]
ikaros has joined #ocaml
EmmanuelOga has joined #ocaml
rwmjones has quit [Ping timeout: 252 seconds]
letrec_ has quit [Ping timeout: 244 seconds]
rwmjones has joined #ocaml
mdelaney has quit [Quit: mdelaney]
Tobu has quit [Ping timeout: 248 seconds]
Tobu has joined #ocaml
mdelaney has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
mdelaney has quit [Quit: mdelaney]
mdelaney has joined #ocaml
mdelaney has quit [Ping timeout: 272 seconds]
othiym23 has joined #ocaml
mdelaney has joined #ocaml
iago has quit [Quit: Leaving]
Submarine has quit [Ping timeout: 252 seconds]
ulfdoz has joined #ocaml
<adrien>
has anyone ever tried the nickle programming language? I don't think it's terrific but I'm curious
iago has joined #ocaml
mdelaney_ has joined #ocaml
mdelaney has quit [Ping timeout: 256 seconds]
mdelaney_ is now known as mdelaney
twittard has quit [Read error: Connection reset by peer]
twittard has joined #ocaml
twittard has quit [Quit: twittard]
mdelaney has quit [Ping timeout: 245 seconds]
Cyanure has joined #ocaml
as has joined #ocaml
as has quit [Client Quit]
everyonemines has joined #ocaml
_andre has quit [Quit: leaving]
probst has joined #ocaml
<probst>
Dear Ocamlers. Is anyone here using _oasis for their builds?
<adrien>
quite a lot of people are
<_habnabit>
someone, probably
<_habnabit>
are you taking a survey?
<probst>
_habnabit: hehe, nope
<_habnabit>
perhaps you meant to ask a more useful question, then
<probst>
I just wonder, does anyone know how to specify options that are sent to the compiler? More specifically I would like to send "-annot" so I get *.annot files
<probst>
_habnabit: sorry for pissing you off. The reason for asking the questions was in order to find someone to ask directly, and not having to cause too much noise here in the room. I am sorry that it clearly backfired
<_habnabit>
nobody is pissed off
<_habnabit>
just trying to encourage you to ask the more useful question first next time
<_habnabit>
it's kind of how irc works
<adrien>
people are shy to answer the "is anyone using X?" questions
<adrien>
as for annot, hmmmmmmmm
<_habnabit>
you can just put `true: annot` in your _tags
<_habnabit>
here's what I have: <**/*.ml>: warn_Z, annot
<probst>
_habnabit: cool. thank you
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
mdelaney has joined #ocaml
asdfhjkl has quit [Quit: Leaving]
twittard has joined #ocaml
Tobu has quit [Ping timeout: 248 seconds]
ivan\ has quit [Ping timeout: 272 seconds]
ivan\ has joined #ocaml
ivan\ has quit [Ping timeout: 252 seconds]
Xizor has joined #ocaml
Tobu has joined #ocaml
ivan\ has joined #ocaml
mcclurmc has quit [Excess Flood]
mcclurmc has joined #ocaml
ivan\ has quit [Ping timeout: 252 seconds]
twittard has quit [Remote host closed the connection]
twittard has joined #ocaml
metasyntax|work has quit [Quit: WeeChat [quit]]
ivan\ has joined #ocaml
ivan\ has quit [Ping timeout: 276 seconds]
ivan\ has joined #ocaml
cdidd has quit [Quit: Leaving]
cdidd has joined #ocaml
ulfdoz has quit [Ping timeout: 265 seconds]
Submarine has quit [Remote host closed the connection]
Snark has quit [Quit: Quitte]
probst has quit [Quit: probst]
twittard_ has joined #ocaml
twittard has quit [Read error: Operation timed out]
twittard__ has joined #ocaml
twittard_ has quit [Read error: Connection reset by peer]
edwin has quit [Remote host closed the connection]
Cyanure has quit [Read error: Connection reset by peer]
everyonemines has quit [Quit: Leaving.]
ivan\ has quit [Ping timeout: 240 seconds]
Tobu has quit [Ping timeout: 272 seconds]
ivan\ has joined #ocaml
Tobu has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
thomasga has quit [Quit: Leaving.]
twittard__ has quit [Read error: Connection reset by peer]
twittard has joined #ocaml
zorun has quit [Read error: Connection reset by peer]
zorun has joined #ocaml
cdidd has quit [Quit: Leaving]
emmanuelux has quit [Ping timeout: 240 seconds]
ivan\ has quit [Ping timeout: 265 seconds]
ikaros has quit [Quit: Ex-Chat]
ivan\ has joined #ocaml
jamii has joined #ocaml
asdfhjkl has joined #ocaml
cdidd has joined #ocaml
antegallya has joined #ocaml
antegallya has quit [Client Quit]
ikaros has joined #ocaml
fraggle_ has quit [Ping timeout: 240 seconds]
letrec_ has joined #ocaml
Tobu has quit [Quit: No Ping reply in 180 seconds.]
Tobu has joined #ocaml
Drup has quit [Quit: Leaving.]
tomprince has quit [Ping timeout: 252 seconds]
tomprince has joined #ocaml
letrec_ has quit [Ping timeout: 244 seconds]
jamii has quit [Remote host closed the connection]
orbitz_ has quit [Quit: moving to linode]
Xizor has quit []
lamawithonel__ has joined #ocaml
lamawithonel_ has quit [Ping timeout: 276 seconds]
MaskRay has joined #ocaml
iago has quit [Quit: Leaving]
oriba has quit [Quit: oriba]
ikaros has quit [Remote host closed the connection]