shawn has quit ["This computer has gone to sleep"]
<hsfb>
let rec sum_map f = function
<hsfb>
[] -> 0.0
<hsfb>
| x :: l -> (f x) +. sum_map f l;;
<hsfb>
<hsfb>
:)
<hsfb>
let entropy = sum_map (fun e -> e *. log2 e);;
<hsfb>
<hsfb>
once more extra parenthesis... fixed
* hsfb
goes dinner.
tvw has joined #ocaml
<tvw>
null
<tvw>
Hi
<tvw>
nobody at home?
<Mr_Awesome>
yes
<Mr_Awesome>
im currently at my place of residence
tvw has left #ocaml []
<Mr_Awesome>
...sorry?
Lena has quit ["Leaving."]
Alleria_2 has joined #ocaml
noteventime has quit ["Leaving"]
Alleria_2 is now known as Alleria
pantsd has quit ["Leaving."]
hsfb has quit [Read error: 104 (Connection reset by peer)]
Alleria_2 has joined #ocaml
Alleria_2 is now known as Alleria_
shawn has joined #ocaml
Alleria has quit [Connection timed out]
Alleria_ is now known as Alleria
pantsd has joined #ocaml
david_koontz has quit ["Leaving"]
shawn has quit ["This computer has gone to sleep"]
shawn has joined #ocaml
shawn has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
thesoko has quit [Remote closed the connection]
thesoko has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
Submarine_ has joined #ocaml
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]
Alleria has quit [Read error: 110 (Connection timed out)]
bzzbzz has quit [Remote closed the connection]
thesoko has quit [Remote closed the connection]
bzzbzz has joined #ocaml
thesoko has joined #ocaml
Lena_2` has joined #ocaml
root`` has joined #ocaml
Lena_2 has quit [Read error: 110 (Connection timed out)]
root` has quit [Read error: 110 (Connection timed out)]
thesoko has quit [Remote closed the connection]
thesoko has joined #ocaml
buluca has joined #ocaml
noteventime has joined #ocaml
Mr_Awesome has quit ["time to impregnate a moth"]
buluca is now known as faboski1
faboski1 is now known as buluca
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
bluestorm_ has joined #ocaml
_noteventime_ has joined #ocaml
noteventime has quit [Connection timed out]
Alleria_ has joined #ocaml
xavierbot has quit [Remote closed the connection]
xavierbot has joined #ocaml
jlouis_ has joined #ocaml
screwt8 has quit [Read error: 104 (Connection reset by peer)]
screwt8 has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
pattern has quit [Read error: 110 (Connection timed out)]
bluestorm_ has quit ["Konversation terminated!"]
test1234 has joined #ocaml
pango_ has joined #ocaml
ygrek has joined #ocaml
pango has quit [Read error: 104 (Connection reset by peer)]
Alleria_ has quit [Read error: 110 (Connection timed out)]
pantsd has quit ["Leaving."]
pattern has joined #ocaml
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
slipstream-- has joined #ocaml
descender has joined #ocaml
ygrek_ has joined #ocaml
ygrek has quit [Remote closed the connection]
slipstream has quit [Read error: 110 (Connection timed out)]
laynor has joined #ocaml
<laynor>
hi, I was wandering if it is possible in ocaml to define a function which prints "hello" and takes no arguments
<laynor>
I can't understand how to do it :-/
Lena has joined #ocaml
<pango_>
functions take at least an argument
<pango_>
so the answer is no
<laynor>
so I'd have to define it with a dummy argument
<pango_>
the standard "dummy argument" is unit
<laynor>
so something like let f unit = print_string("hello\n");;?
<laynor>
pango_: sorry but I'm a noob with ocaml :-/
<pango_>
mmh did you read any doc about OCaml yet?
<Smerdyakov>
laynor, what source are you following to learn OCaml?
<laynor>
Smerdyakov: I'm learning it from my univeristy lessons, but it isn't a course about OCaml, so I'm reading some of the manual as well.
<Smerdyakov>
laynor, read the tutorial before asking any more questions here.
<laynor>
Smerdyakov: could you point me to it? that would be nice
<Smerdyakov>
laynor, read the manual table of contents.
<laynor>
lol I'm feeling stupid :O it was as simple as () -_-''
<Smerdyakov>
The only thing to feel stupid about is guessing about how to do something instead of reading a tutorial or textbook first. ;)
Lena_2` has quit [Remote closed the connection]
root`` has quit [Remote closed the connection]
Demitar has quit ["Burn the land and boil the sea. You can't take the sky from me."]
Demitar has joined #ocaml
bluestorm_ has joined #ocaml
<laynor>
Smerdyakov: I'm not so "out of caml", but indeed I've never had the need to work with units, so I lost the () trick ^^; can you tell me if there is a better way to do this: http://rafb.net/p/kUTzrH82.html ?
<Smerdyakov>
laynor, you have some redundant parentheses, but the abstract syntax looks fine to me.
<laynor>
:-)
Gabriell has joined #ocaml
<laynor>
another noob question, let's say I want a function which returns values of type int or float, are variant types the only way to do the thing?
<Lena>
you can write polymorphic functions
<Gabriell>
Hey all! I'd like to get my hands on a fairly small project done in ocaml. I have plans for writing something myself and I think I'd like to have a look at something small that has makefiles and config and the like but with a very small footstep. Any suggestions?
<Smerdyakov>
laynor, did you read the whole tutorial yet?
<laynor>
Smerdyakov: no, I'm stil reading it, but it's quite long, and I'm curious :P
<Smerdyakov>
laynor, well, it's a bad idea to write anything until you're done reading it, unless you are following a list of exercises chosen to be doable with information already presented.
<laynor>
Smerdyakov: the last question was not about somehting I "have" to write, I knew variants and was just wandering.. as of now, the things I have to do with ocaml just use variants, modules, pattern matching, arrays and references
<Smerdyakov>
laynor, answer stays the same. The tutorial is short and ought to be read before proceeding.
rwmjones_ has joined #ocaml
<rwmjones_>
let f list = List.map2 (=) list;;
<xavierbot>
val f : 'a list -> 'a list -> bool list = <fun>
<rwmjones_>
let g = List.map2 (=) ;;
<xavierbot>
val g : '_a list -> '_a list -> bool list = <fun>
<Smerdyakov>
g [1; 2];;
<xavierbot>
- : int list -> bool list = <fun>
<Smerdyakov>
HAH! I collapsed your waveform!
<Smerdyakov>
g;;
<xavierbot>
- : int list -> int list -> bool list = <fun>
<rwmjones_>
indeed ... did you see Jon's posting just now to ocaml_beginners?
<rwmjones_>
I have a library which I have successfully imported into CIL
<rwmjones_>
I have its entry points
<Smerdyakov>
rwmjones, did you follow the links to the submodule signatures for Dataflow?
<rwmjones_>
sure, I just didn't understand exactly what I was supposed to write
<rwmjones_>
an example would help though
<rwmjones_>
ok, so the library:
<Smerdyakov>
I've never used that stuff, but it looks straightforward enough. I would just follow that documentation.
<Smerdyakov>
You need to choose if you want a forwards or backwards analysis.
<Smerdyakov>
Then write a ForwardsTransfer or a BackwardsTransfer.
<Smerdyakov>
And instantiate it with the appropriate functor.l
<rwmjones_>
I want to prove that for each entry point (a function call into the lib), if the function returns -1 (indicating error) then at some point the library function called a certain "error" function exactly once
<rwmjones_>
yeah, I guess I don't know what a "forwards/backwards analysis" is
<rwmjones_>
anyway, see second question ^^
<Smerdyakov>
Oh dear.
<Smerdyakov>
Find a compiler textbook.
<rwmjones_>
yeah, I'll get my dragon book out of storage
<Smerdyakov>
Ew.
<Smerdyakov>
Appel is better.
<rwmjones_>
I can do ^^ easily enough if the function returns a constant
<rwmjones_>
but what if the function returns a variable - need dataflow analysis, I guess, but I'd like some indications how to proceed / know if anyone has example code
<Smerdyakov>
It's not going to be simple.
<Smerdyakov>
You probably know that this is undecidable in general.
<rwmjones_>
well, if it gets 90% of the case, that's fine - I can hand-prove or rewrite the rest of the code
<Smerdyakov>
You'd probably be better served starting from BLAST.
<rwmjones_>
ummm BLAST?
<rwmjones_>
what is the Appel book you were referring to?
<Smerdyakov>
Andrew Appel, Modern Compiler Design in [ML|Java|C]
<rwmjones_>
sure, which one though :-) I'm guessing the ML one
<rwmjones_>
fucksocks, the ML one is $100
<Smerdyakov>
Yeah, that's the right one for anyone who doesn't have some ridiculous language handicap.
<Smerdyakov>
But, worry not. You don't need to understand anything special to use BLAST.
<Smerdyakov>
If it works, you're done, with no need for a textbook.
<rwmjones_>
the BLAST page is interesting, thanks
<Smerdyakov>
Just specify what properties you want to check via little automata and run.
<rwmjones_>
what these berkeley guys lack is an overview ... I was originally looking at CCured, until someone on their team pointed me to Deputy (which doesn't work) and now I find BLAST
* rwmjones_
grumbles
<Smerdyakov>
Disclaimer: I am one of those Berkeley guys.
<rwmjones_>
well, write an overview page!
<Smerdyakov>
An overview would imply greater organization than there is. It's just an accident that these projects happened all at Berkeley, really.
<rwmjones_>
& get it into Google ... perhaps you should buy some Google Ads in case people search on these terms
<rwmjones_>
cool, I'll have a look at BLAST, then maybe I'll have some more intelligent questions
<Smerdyakov>
And also understand that these are research projects, such that the system penalizes the people involved for spending time on advertising or documentation-writing.
<rwmjones_>
yeah, I understand
<rwmjones_>
although the documentation for CIL is pretty good
<rwmjones_>
apart from the stuff about dataflows
* rwmjones_
was drawing lovely graphviz graphs today using CIL
<Smerdyakov>
The dataflow documentation is perfectly fine.
<Smerdyakov>
It assumes 1980's compiler common knowledge. :P
<Smerdyakov>
CIL is designed for programming language researchers.
<rwmjones_>
not for someone who last read the dragon book 15 years ago, but yes you're probably right
<rwmjones_>
is BLAST based on CIL?
<Smerdyakov>
BLAST uses CIL for input, which is a tiny part of the problem.
<rwmjones_>
the parsing ability of CIL is excellent
<Smerdyakov>
BLAST is really a pretty hardcore theorem prover.
<rwmjones_>
I mean, in real world terms - ie. handling all the gcc cruft
<Smerdyakov>
Yes, parsing and elaborating real world C programs is hard, but automatic proofs about programs are harder in a more scientifically-interesting way.
_noteventime_ has quit [Remote closed the connection]
noteventime has joined #ocaml
buluca is now known as bulucagay
Mr_Awesome has joined #ocaml
bulucagay is now known as buluca
kelaouchi has joined #ocaml
pascal has joined #ocaml
<pascal>
hello; I've got a problem with constants that should not be:
<pascal>
let f = Random.int 42 ;; yields always the same value...
<pascal>
how can I force it to execute the random-function every time f is called?
<pango_>
f is not a function in this code
<pascal>
so should I use "let f _ =..."? and call it as "f ()" ?
<pango_>
or let f () = ..., so users of the function know it's not waiting for parameters
<pascal>
thanks :)
Nucleo has left #ocaml []
<rwmjones_>
Random.int ;;
<xavierbot>
Characters 1-11:
<xavierbot>
Random.int ;;
<xavierbot>
^^^^^^^^^^
<xavierbot>
Unbound value Random.int
<rwmjones_>
hmm, should include that
pascal has quit ["Verlassend"]
kelaouchi has quit [Read error: 110 (Connection timed out)]
tty56_ has joined #ocaml
tty56 has quit [Read error: 110 (Connection timed out)]
ygrek_ has quit []
jlouis_ has quit [Read error: 110 (Connection timed out)]
buluca has quit [Excess Flood]
buluca has joined #ocaml
jlouis has joined #ocaml
mnemonic_ has joined #ocaml
mnemonic_ has quit [Client Quit]
mnemonic has quit [Read error: 110 (Connection timed out)]
test1234 has quit [Read error: 110 (Connection timed out)]
mnemonic has joined #ocaml
rwmjones_ has quit ["Leaving"]
slipstream-- has quit [Remote closed the connection]