yangsx has quit [Read error: 60 (Operation timed out)]
eviltoylet has joined #ocaml
<eviltoylet>
can someonehelpme with the usage of 'in' ?
<mauke>
what's the problem?
<eviltoylet>
i'm not quite sure how to use it
<mauke>
are you talking about let .. in?
<eviltoylet>
yah
<mauke>
it's used to define local constants
<mauke>
let NAME = VALUE in EXPRESSION
<eviltoylet>
so its only valid for that expression ?
<mauke>
yes
<eviltoylet>
whats the scope for a let inside a let?
<mauke>
example?
<eviltoylet>
say you're just using a let = in a function declaration
<eviltoylet>
does that persist only until the end of the function declaration?
<eviltoylet>
*that in up there was not intended
<mauke>
like this? let foo a b = let a' = bar a in a' + b
<eviltoylet>
mmm, i guess something like that. does a' exist outside of the function foo?
<mauke>
no, only in the expression a' + b
<eviltoylet>
thanks mauke :)
<eviltoylet>
and if you wouldn't mind, one more question?
<mauke>
just ask
<eviltoylet>
let me try somethign first to see if the question goes away :D
<eviltoylet>
okay i got it. thanks. there's no way to return nothing right?
<mauke>
well, you can return ()
<mauke>
it's still a value but the only value of its type
<mauke>
or you could throw an exception
Naked has joined #ocaml
Naked is now known as Hadaka
<eviltoylet>
oh. how do i throw an exception?
<mauke>
with raise
<eviltoylet>
ahh thanks mauke
cjohnson has quit [Remote closed the connection]
eviltoylet has left #ocaml []
Sonarman has quit ["leaving"]
ulfdoz_ has joined #ocaml
ulfdoz has quit [Read error: 145 (Connection timed out)]
eviltoylet has joined #ocaml
<eviltoylet>
how do i use a module in ocaml? Say i want to use length from module list
<eviltoylet>
or , a better question is there any built in function to remove duplicates in a list?
<Nutssh>
You're better off doing a hash table or set for that.. Doing that with a list would be O(n^2).
<eviltoylet>
not too worried about efficiency
<eviltoylet>
is there a built in function, or do i hve to write it mysleF?
<mauke>
I don't see a built-in function in the List module
<mauke>
let remove_dups l = let rec remove_dups_r l a = match l with [] -> a | (x :: xs) -> remove_dups_r xs (if List.mem x a then a else x :: a) in remove_dups_r l [] (* untested *)
<Nutssh>
let remove_dups l = List.filter (fun x -> not (List.mem x l))) l
<Nutssh>
Also untested.
<mauke>
um, isn't that equivalent to fun _ -> []?
<eviltoylet>
lol
<Nutssh>
I try to not manually match-with over a list if I can avoid ti.
<mauke>
your function says: "remove all elements of l that are in l"
* Nutssh
laughs, "oops"
<eviltoylet>
do you guys use ocaml for work ?
<mauke>
no, just for fun
<eviltoylet>
oh , fun as in making applicatoins?
<mauke>
I wouldn't call them applications; they're mostly just snippets of code and small programs
<eviltoylet>
oh -- practical?
<Nutssh>
I use it in my research, writing random software that I need. A few kloc/year.
<eviltoylet>
or just for the hell of it
<mauke>
someone mentioned it on EFnet/#perlhelp and it looked interesting, so I started doing simple stuff in it
<mauke>
it was cool, with autocurrying, pattern matching, higher order functions, ...
<mauke>
but now I'm trying to grok haskell and monads
<eviltoylet>
oh
<eviltoylet>
interesting, im just learning about it because of class
<eviltoylet>
would never have known :D
<araujo>
Hello.
<eviltoylet>
hello
angagon has joined #ocaml
<eviltoylet>
is == not overloaded for strings?
<mauke>
== works for any type, why?
<eviltoylet>
"hello" == "hello" seems to return me false
<mauke>
yes
<mauke>
== compares the memory addresses
<mauke>
it tests whether two objects are physically identical
<eviltoylet>
hrmm, so how do i compare the values?
<mauke>
use =
<mauke>
and <> for inequality
<eviltoylet>
doing let x = 2, let y=2 , and x==y seems to give me true though
<mauke>
yeah, integers are unboxed
<araujo>
== is like testing for inmutable objects right?
<mauke>
huh?
<araujo>
objects that you can't change... for example, numbers, chars...
<mauke>
[2] == [2];; - : bool = false
<mauke>
lists are immutable
<eviltoylet>
hrmm, o caml can't compare functions can it?
<eviltoylet>
like if a function does something, and another function does something else, can i compare them and see if they do the same thing or not?
<mauke>
no, that's fundamentally impossible AFAIK
<eviltoylet>
yah i know :)
<mauke>
infinite loop: let rec a = 0 :: b and b = 0 :: a in a = b;;
<araujo>
hah, you are asking too much already eviltoylet :-)
<eviltoylet>
hey it was worth a shot
<eviltoylet>
iremmebr the pain of recognizable and decidable languages
<eviltoylet>
haha
<Nutssh>
It is fundamentally impossible except in restrictive languages. (Eg, automata)
Sonarman has joined #ocaml
vezenchio has quit [""Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule—and bot]
Herrchen has joined #ocaml
araujo has quit ["Programs must be written for people to read, and only incidentally for machines to execute"]
Herrchen has quit ["leaving"]
<mflux>
filtering duplicates from a list doesn't need to be O(N^2), only O(n log n)
<mauke>
does that preserve the original order?
<mflux>
you can always pair the data with the order and sort it again afterwards, which is O(n log n)
<Nutssh>
O(n) with a hash table.
<mflux>
except worst case ;)
<mflux>
hm, well
<mflux>
how fast is constructing a perfect hash?
eviltoylet has left #ocaml []
<ulfdoz_>
re
<ulfdoz_>
One should denote, that the linear complexity of a hashtable is only an expactation. The worst case depends on collision handling.
<ulfdoz_>
s/exapc/expec/1
<ulfdoz_>
mflux: Why should one care about. You 're doing it once or twice in the lifetime of the table?
<mflux>
ulfdoz_, who knows, maybe the table is huge and full of evil data?
<mflux>
maybe a firewall uses it for priorizing packets and a hacker can exploit the hash function to bring it to its knees
<ulfdoz_>
mflux: Never seen a case like this, but theoretically possible.
<mflux>
I think there was a related vulnerability in iptables quite some time ago
<ulfdoz_>
Sounds reasonable. Indeed a rehashing could solve the problem.
Herrchen has joined #ocaml
<ulfdoz_>
You here? :)
<Herrchen>
moin
smimou has joined #ocaml
<mflux>
yes
<mflux>
didn't feel that needed much adding ;)
<mflux>
I wonder what the criteria for rehashing should be, or just randomly
<mflux>
or after n collides
<ulfdoz_>
I would prefer the n collides, just for simplicity.
<mflux>
hmm.. if it were (log total_number_of_values) would it be amortized to constant too? I imagine so
<mflux>
or no, it of course depends on the data
<mflux>
but even after initializing the hashing function with random parameters the hacker should have tough time colliding it on purpose, without much feedback on the hashing
<Herrchen>
what about adaptive hashing methods?
<mflux>
I haven't dealed with those
<mflux>
but maybe if the need arises, I'll know the word to google for, thanks ;)
<Herrchen>
what attacks do you fear, what is the "setup", if I may ask?
<mflux>
purely thinking from the theoretical pov, I've been employed by a security product vendor earlier though
<Herrchen>
theoretical you shouldn't get anything better than O(log n) for most operations if you want to have a dictionary
<Herrchen>
O(1) would be nice, but if you get really bad input, I think you can't guarantee this
<angagon>
nice thing, of course, is you can guarantee O(log n) operations with balancing binary trees
<Herrchen>
anyway I am a way a bit - bbl
<Nutssh>
You could look at the solution proposed in the crosby&wallach paper.
Sonarman has quit ["leaving"]
araujo has joined #ocaml
<araujo>
Hello ocaml'ers
oracle1 has joined #ocaml
vodka-goo has joined #ocaml
shawn_ has joined #ocaml
_shawn has quit [Read error: 110 (Connection timed out)]
Gueben has joined #ocaml
<kleenest>
'lo all
<araujo>
Hello kleenest
Gueben has quit [Remote closed the connection]
Gueben has joined #ocaml
kleenest is now known as kleene-kaah
Gueben has quit ["Leaving"]
Gueben has joined #ocaml
Gueben has quit [Client Quit]
two-face has joined #ocaml
<vincenz>
hi
<two-face>
Hi
Herrchen has quit ["bye"]
Gueben has joined #ocaml
cjohnson has joined #ocaml
cjohnson has quit [""We live like penguins in the desert...""]
d-bug has joined #ocaml
_JusSx_ has joined #ocaml
two-face has quit ["Leaving"]
cjohnson has joined #ocaml
bzzbzz_ has joined #ocaml
bzzbzz has quit [Read error: 110 (Connection timed out)]
d-bug has quit ["Lämnar"]
pango_ has joined #ocaml
vezenchio has joined #ocaml
pango has quit [Read error: 110 (Connection timed out)]
smimou has quit [Read error: 60 (Operation timed out)]
smimou has joined #ocaml
cognominal_ has joined #ocaml
two-face has joined #ocaml
cognominal_ has quit ["Leaving"]
smimou has quit ["?"]
vodka-goo has quit []
two-face has quit [Read error: 110 (Connection timed out)]
Sonarman has joined #ocaml
haakonn has joined #ocaml
haakonn_ has quit [Read error: 110 (Connection timed out)]
TeXitoi has joined #ocaml
senko has joined #ocaml
senko has left #ocaml []
TeXitoi has quit ["leaving"]
_JusSx__ has joined #ocaml
mr_pengy has joined #ocaml
_JusSx_ has quit [Read error: 110 (Connection timed out)]
_JusSx_ has joined #ocaml
_JusSx_ has quit [Client Quit]
_JusSx__ has quit [Read error: 110 (Connection timed out)]