MaskRay has quit [Remote host closed the connection]
MaskRay has joined #ocaml
The_third_man has joined #ocaml
tzictli has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
pango is now known as pangoafk
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
edwin has joined #ocaml
ftrvxmtrx has joined #ocaml
tzictli has left #ocaml []
NihilistDandy has quit []
cyphase has quit [Ping timeout: 260 seconds]
thomasga has joined #ocaml
antegallya has joined #ocaml
willb has quit [Ping timeout: 260 seconds]
willb has joined #ocaml
emias has joined #ocaml
antegallya has quit [Ping timeout: 272 seconds]
djcoin has joined #ocaml
cyphase has joined #ocaml
ikaros has joined #ocaml
Xizor has joined #ocaml
<ppilatus>
Hello, what is the name of `not' function in OCaml?
<ppilatus>
That is, boolean negation
<djcoin>
not ?
<ppilatus>
uh
<ppilatus>
right
<ppilatus>
sorry
<djcoin>
:)
<ppilatus>
I have another question however. I have this code for modelling NFAs: http://ideone.com/wihig it is actually F#, but I think the idea is simliar. 's here is a type for states and 'a - type for letters. Now, I want to construct an function which converts a NFA to a NFA with only one final state. The problem is, that means I have to add additional state: adding another value to the type 's. Is it even possible to do that?
<ppilatus>
Should I stop using types for representing sets for states/alphabets? Would it be better to use states instead?
goncalo has quit [Remote host closed the connection]
avsm has joined #ocaml
Obfuscate has joined #ocaml
Tobu has joined #ocaml
dwhj has joined #ocaml
NihilistDandy has joined #ocaml
Submarine has quit [Ping timeout: 252 seconds]
silver has quit [Ping timeout: 240 seconds]
letrec has joined #ocaml
antegallya has joined #ocaml
ulfdoz has joined #ocaml
emmanuelux has joined #ocaml
silver has joined #ocaml
<everyonemines>
ppilatus: Use variant types if the set is fixed. Otherwise use a hashtable.
<everyonemines>
That's my suggestion.
<flux>
(or Set.t if you want to stay functional)
djcoin has quit [Ping timeout: 272 seconds]
<flux>
actually hmm right, it's a bit tricky in that case perhaps
<everyonemines>
I don't mind not having a generic print that much, but what you hear from people learning ocaml is
<everyonemines>
1) no generic print 2) wtf are refs
<everyonemines>
or "why can't i mutate this variable"
<everyonemines>
I have to admit that ocaml is not noob-friendly for someone coming from C or java
roha has joined #ocaml
<everyonemines>
and for that problem I don't think "but you can patch it, sort of, with this 3rd party thing" will satisfy people :-/
<flux>
well, there is a chance in near (?) future we will see some runtime type capabilities or generic printing
<flux>
in practice it -is- kinda annoying to have to write generic printers for your datastructures when debugging. and Std.dump doesn't always fit the bill.
wwi has joined #ocaml
<flux>
whereas dynamic languages make it so easy.
<wwi>
bonjour
<everyonemines>
Well, that patch isn't a generic printer for new datastructures.
<everyonemines>
They could just implement generic print in the interpreter
<everyonemines>
with a special function that gets removed during compilation.
<flux>
hmm, it works for everything that has string_of defined? and you can locally define them for external data structures
<everyonemines>
oh, that's how it works
<everyonemines>
an OO sort of thing
<flux>
I think it would automatically work for, say, map of maps of strings to ints
<flux>
that kind of pretty printer would be annoying to write, especially for a newbie
<flux>
and should there be some unsupported datatype, you can (?) just write let string_of_blahgargh a = .. in show your_data_structure_involving_blahgargh
<flux>
haven't tried it though :)
<flux>
of course, the bad sode of %show is that it doesn't generalize
<flux>
when you see that working, you want more, and you get disappointed that it's some compiler majikk :)
<flux>
(much like printf)
<everyonemines>
printf is kind of ugly too
<everyonemines>
well, not worse than in C I guess
<flux>
well, better actually, because it's safe
<flux>
and I prefer to use it for all my formatted output needs
<everyonemines>
I mean in terms of implementation hackery
<flux>
sure
<flux>
I think the C version is a lot simpler ti implement, though :)
ulfdoz has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
wwi has quit [Remote host closed the connection]
djcoin has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
emmanuelux has quit [Read error: Connection reset by peer]
emmanuelux has joined #ocaml
roha has quit [Remote host closed the connection]
Tobu has joined #ocaml
ontologiae has joined #ocaml
<ontologiae>
hi all
<djcoin>
hi
EmmanuelOga has joined #ocaml
ulfdoz has quit [Quit: kernel-upgrad]
antegallya has quit [Read error: Operation timed out]
ulfdoz has joined #ocaml
iago has joined #ocaml
leoncame` has quit [Quit: Asta la vista]
Kakadu has quit [Quit: Page closed]
antegallya has joined #ocaml
<thelema>
ppilatus: use functors and provide a function to create a new state
scottmcl66 has joined #ocaml
<thelema>
ppilatus: or pass in as argument to your conversion function a helper that will build a state of the right type
<thelema>
(it's harder to review pull requests when they modify things repeatedly.)
<thelema>
I see you didn't go for exponential resizing
<thelema>
it looks like there's a bunch of functions that got un-implemented
jave has quit [Ping timeout: 276 seconds]
jave has joined #ocaml
spearalot has quit [Quit: Computer has gone to sleep]
NihilistDandy has joined #ocaml
student202 has joined #ocaml
<student202>
Can anyone help me with creating a certain function in ocaml?
<_habnabit>
I dunno; can anyone?
<student202>
Can you :)?
<_habnabit>
how am I supposed to know
<NihilistDandy>
(fun x -> x+1)
<_habnabit>
I'm not omniscient
<thelema>
student202: just ask your question
<NihilistDandy>
I'm mathematically certain that's a function
<student202>
Alright, I have a list and I want to check every element against itself in that list for some certain property.
<adrien>
(+) 1
<thelema>
List.filter?
<thelema>
List.exists? List.for_all?
<student202>
Still not quite clear how to do so
ski has quit [Ping timeout: 248 seconds]
<thelema>
student202: what's the return type of your function?
<_habnabit>
well, you haven't explained _what_ you want to do
<student202>
I would ideally want to to return a boolean
<thelema>
student202: and that boolean is true only when all elements in the list have the property?
<student202>
for example the problem is based off units
<thelema>
let l = [2;4;6] in let p x = x mod 2 = 0 in List.for_all p l
<student202>
so if I have FT LBS M S
<student202>
that would be an invalid list because ft and m share the same base unit: which is m
<thelema>
you want to see if any pair of elements have a paired property?
<student202>
basically yes
<student202>
I'll give another example
<thelema>
let rec test_pairs p = function [] | [_] -> true | x::tl -> not (List.exists (p x) tl) && test_pairs p tl
<student202>
Yeah this seems like it would work
<student202>
basically no two elements in the list cannot have the same property of sharing a base unit
<thelema>
it's O(n^2). If you can categorize your items, you could probably drop the complexity down to O(dn) with d categories
<thelema>
or maybe even O(n)
<student202>
thanks for the help, i'll see if this works and try to dissect what it's saying lol
<thelema>
although it'd be a bit more code.
edwin has quit [Remote host closed the connection]
<student202>
I'm still quite lost even with some help. The function I am trying to write takes in a list. It is a list of base units (grams, seconds, meters) or a list of derived units, units that are derived from the base units, such as kg, km and min. Basically the list that I generated can have combinations of those units. Like [km;m;s;min] but I want to call a function on this list to make sure that every unit in the list do not shar
<student202>
For the case of [km;m;hour;min] this would be an invalid list because km and m share the base unit m, and hour and min share the base unit seconds
<thelema>
do you have a function to tell if a pair is invalid?
<student202>
No but I could write one, it basically would just read from a hashtable to see its base unit
<thelema>
write one, call it 'p' and use test_pairs p l
<student202>
Alright.
cdidd has quit [Remote host closed the connection]
<gildor_>
thelema: I am back
<gildor_>
thelema: what do you mean by un-implemented ?
<thelema>
gildor_: oops, misread
<thelema>
gildor_: I must have been looking at an earlier commit where intersect/etc. weren't implemented
<thelema>
I see now the apply_set_op function
<gildor_>
thelema: the .mli is fully implemented in the new version
<gildor_>
thelema: and if you run the tests on the old version, you'll see that there are various bugs
<thelema>
out of curiosity, do you recall the bugs you found?
<gildor_>
thelema: yes, one of them is wiht create_full
<thelema>
creating the last few elements in the set?
<gildor_>
the doc said that its count must match the parameter
<thelema>
I noticed the code to handle that - good check
<thelema>
s/check/catch/
<gildor_>
wait a minute, I'll switch to the ref branch
<gildor_>
AFAIR, there was a bug in diff or sym_diff
<gildor_>
no, it was in diff (test diff1)
<gildor_>
if one bitset is longer than the other, the difference of size if filled with bit set
<gildor_>
e.g. if you diff 2 sets of 5 elements, you get 130 elements at the ened
<gildor_>
thelema: ^^^
<thelema>
ah, diff fills with 0xff instead of 0x00? That's a big oops
<gildor_>
next time, I'll rebase before pushing, it will ease your work
<thelema>
yes, please.
<thelema>
gildor_: pull request merged
<gildor_>
thelema: L316 of the previous version
<gildor_>
thelema: even the comment is false
* gildor_
not a git/github expert
<thelema>
yes, that code is not correct for diff.
<thelema>
I think those three lines shouldn't be there. only extra a bits should get copied.
<thelema>
but anyway...
<thelema>
four lines
<thelema>
thanks for your help. I'm tempted to throw together a version of bitset using bigarray (or maybe float arrays and Int64.of_float) to get larger block sizes for scanning
<thelema>
although if the set is really that sparse, a int Set.t might be better
<gildor_>
thelema: you can try a bigarray for size, but you won't get a big performance improvement
Tobu has quit [Ping timeout: 260 seconds]
<thelema>
well, I'd want to use an int array, but mod 63 or mod 31 isn't so nice.
<gildor_>
thelema: knowing that on 32bit computer you can already store 128M integers in a bitset
<gildor_>
thelema: oh, i tried a int array (63)
ontologiae has quit [Ping timeout: 272 seconds]
<gildor_>
thelema: not big perf improvement
<thelema>
ok.
<gildor_>
thelema: keep in mind that there is a write barrier
<thelema>
not for ints
<thelema>
only for pointer values
<gildor_>
so if you store whatever in a int array it'll check the write barrier first
<gildor_>
it won't check the int, because it is an immediate value, but it'll check the array
<thelema>
really?
<thelema>
interesting...
<gildor_>
not 100% sure, it needs to be checked
<thelema>
`a.(5) <- 3` shouldn't involve any write barrier
<_habnabit>
is there a simple way of getting the 5th through last elements of an array? I thought BatArray had a thing, but I don't see it
<_habnabit>
reading over it again
<thelema>
hmm, I thought I added a 'tail' function to array. Maybe I only did for strings
<_habnabit>
so just Array.sub ?
<thelema>
yup, only strings. should copy that over.
<thelema>
yes. I'll add in Array.head,tail,first,last to get slices identified by position or length
<_habnabit>
hooray, thanks
<thelema>
(or you can do it and save me the work - they're already implemented in BatString
<_habnabit>
atm is not a good time; maybe tomorrow, but I have too many things I need to finish today
<thelema>
ok, I'll probably do it by then
<gildor_>
thelema: anyway, concerning int array vs string the logic is almost the same
<gildor_>
thelema: but char are small enough to play with intermediate array (likt next_set_bit_array) which are a big performance win
<gildor_>
thelema: all in all string ref is the best implementation i have
<gildor_>
thelema: (I had a look at the asm generated by an assignement in a string, and think there is no write barrier involved)
* gildor_
time to go to bed
<thelema>
yes, next_set_bit_array is nice.
<thelema>
it'd have to be broken up for ints
<thelema>
maybe 16b at a time
<thelema>
good night.
Tobu has joined #ocaml
mifadir has quit [Quit: Quitte]
avsm has quit [Quit: Leaving.]
Jetbeard has joined #ocaml
<Jetbeard>
dear god, I've been up far too long
<Jetbeard>
the OCaml compiler is complaining about a syntax error on the following line of code: " iter (fun (x, l) -> gen (CASEARM x l)) arms;
<Jetbeard>
can anybody immediately spot what's wrong with this and tell me why i'm being stupid?
<_habnabit>
it's probably something not on that line
<Jetbeard>
It compiles just fine without that line
<_habnabit>
oh, that's right
<_habnabit>
did you mean CASEARM (x, l) ?
<_habnabit>
forgot about ocaml's crazy init-upper vs. init-lower fetish
<Jetbeard>
ah yes, it's possible i do
<Jetbeard>
that's fixed it, thanks
<Jetbeard>
iter (fun (x, l) -> gen (CASEARM x l)) arms;
<Jetbeard>
oops disregard that, middle-click paste etc.