<spicey>
What should I do to be able to break on a function name for the executable built with help of OCamlMakefile in ocamldebug? all: debug-code seems to allow to break only on line number, not function name: http://codepad.org/oJrI2SKc
<kaustuv_>
thelema: for instance, I believe my proposal is isomorphic to the one in Okasaki's "Purely Functional Data Structure" book.
ulfdoz has quit [Ping timeout: 276 seconds]
ulfdoz has joined #ocaml
infoe has quit [Ping timeout: 276 seconds]
ulfdoz has quit [Ping timeout: 276 seconds]
<thelema>
kaustuv_: O(1) amortized for every operation?
<kaustuv_>
O(1) amortized for front and rear, yes
mattam has quit [Ping timeout: 276 seconds]
<thelema>
kaustuv_: nice.
seafood has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
<thelema>
I'm happy with both now, I'll merge them and if you want to investigate the alternate union-find (C-inspired) implementation, feel free to switch things
<kaustuv_>
If you merge the deque one, can you pull from the deque-clean branch?
<thelema>
will do - I was just trying to figure out the difference, is it just the commit message?
<kaustuv_>
some corrections to the comments as well
<thelema>
ok.
<kaustuv_>
thanks again
<thelema>
thank you for (I assume) cleaning up your code for batteries
<dark>
thelema, what do you mean? (about SMP). i thought that using multiple cores would mean SMP
<thelema>
dark: message passing is probably how multiple cores will work past 4 or so
<kaustuv_>
it's how they already work, but the message passing is done in hardware
<dark>
there are already consumer-grade six-cores cpus
<dark>
hm
<thelema>
yes, and that doesn't scale well.
<kaustuv_>
the future is numa anyway (numa numa iei!)
<thelema>
does numa include private memories for different cores?
<thelema>
numa seems to imply still universally accessible address spaces
<kaustuv_>
dunno about private, but there are definitely core-local memories in the sense that your access time to your local memory is order(s) of magnitude faster than other memory
<dark>
Non-Uniform Memory Access or Non-Uniform Memory Architecture (NUMA) is a computer memory design used in multiprocessors, where the memory access time depends on the memory location relative to a processor.
kaustuv_ has quit [Quit: Out of battery]
seafood has quit [Ping timeout: 260 seconds]
surikator has joined #ocaml
sdfjsdfk has joined #ocaml
<sdfjsdfk>
so i want to take a pair containing parits like this: ((a,b),(c,d)) so the function is 'let a = ' where a is the pair of pairs
<sdfjsdfk>
and calculate the dot product
<sdfjsdfk>
so i am doing this: let dist a = let x = fst a; let y = snd a;
<sdfjsdfk>
using nested let's
<sdfjsdfk>
but i am not sure if this is correct
<sdfjsdfk>
so, x and y are pairs
<dark>
hm? to work with pairs i often use pattern matching
<dark>
instead of using fst, etc
<thelema>
let dist ((a,b),(c,d)) = a*c + b*d
<dark>
yes, that way
<sdfjsdfk>
the function has to be of the form: let dist a =
<dark>
but it is in this form
<dark>
just that the pattern-match on the argument isn't a variable, but a tuple
<thelema>
let dist a = let (a,b),(c,d) = a in (a *. c) +. (b *. d)
<dark>
ha
<dark>
or let dist a = match a with (a, b), (c, d) -> a*c + b*d
<thelema>
:)
<dark>
but when i see this pattern i do let dist = function (a, b), (c, d) -> .. and when i see this pattern i do let dist ((a, b), (c, d)) = ..
<sdfjsdfk>
so how do i get this to work with floats
<sdfjsdfk>
just use *.?
<thelema>
and +.
<sdfjsdfk>
gotcha thanks
<sdfjsdfk>
has anyone here tried to reverse compile ocaml byte code? or is this pretty much impossible?
<thelema>
It's been asked before, I dunno if anyone's done it.
<dark>
reverse compile? i know of a compiler that transforms ocaml bytecode into javascript
<sdfjsdfk>
dark: really? how do i get this
<sdfjsdfk>
acutally idk if that will help me that much
<dark>
i actually think there are two systems for compiling ocaml to javascript o.o
<thelema>
sdfjsdfk: the prof gives bytecode compiled versions of your assignments?
<sdfjsdfk>
i think last semester they did
<dark>
oh haha
<sdfjsdfk>
the professor last year said if could reverse compile the byte code you got an A+ for the class
<thelema>
:)
<dark>
the program is used for what, to test of your answer is correct?
<dark>
i think that you could just run it in the debugger
<thelema>
sdfjsdfk: are you skeptical?
<sdfjsdfk>
idk they made it seems like it was a huge undertaking
<sdfjsdfk>
it was to make sure your program was correct
accel has joined #ocaml
surikator has quit [Quit: surikator]
<thelema>
yes, definitely need to rewrite this stupid ruby script
rks has quit [Ping timeout: 265 seconds]
<elehack>
Bug #8: the script is in Ruby
<thelema>
bug #1: the script uses regular expressions... badly. But I repeat myself.
* thelema
refrains from quoting Zawinski
<elehack>
lol
joewilliams_away is now known as joewilliams
rks has joined #ocaml
<thelema>
grr, I randomly get linking errors related to not including threads when compiling the quicktests (as one .cma) with batteries...
Amorphous has quit [Ping timeout: 272 seconds]
boscop__ has joined #ocaml
boscop_ has quit [Ping timeout: 240 seconds]
<thelema>
sometimes ocamlbuild doesn't add -package threads when I clearly have "<*>: pkg_threads
<thelema>
ah, batteries is using a wierd myocamlbuild...
Amorphous has joined #ocaml
drunK has quit [Remote host closed the connection]
sun28 has quit [Ping timeout: 260 seconds]
eye-scuzzy has joined #ocaml
myu2 has joined #ocaml
eye-scuzzy has quit [Remote host closed the connection]
eye-scuzzy has joined #ocaml
joewilliams is now known as joewilliams_away
jonafan_ has joined #ocaml
jonafan has quit [Ping timeout: 240 seconds]
boscop__ has quit [Ping timeout: 240 seconds]
elehack has quit [Ping timeout: 240 seconds]
elehack has joined #ocaml
smerz has joined #ocaml
elehack has quit [Quit: Farewell, programs.]
sdfjsdfk has quit [Quit: Page closed]
edwin has joined #ocaml
Snark has joined #ocaml
ygrek has joined #ocaml
tnguyen has joined #ocaml
orion1010 has joined #ocaml
Associat0r has joined #ocaml
seafood_ has joined #ocaml
tnguyen has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
seafood_ has quit [Ping timeout: 276 seconds]
spicey has left #ocaml []
seafood_ has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 255 seconds]
ftrvxmtrx has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 246 seconds]
ftrvxmtrx has joined #ocaml
seafood_ is now known as seafood
lars9 has joined #ocaml
<lars9>
what do these two lines mean: type 'a ivar;; type 'a deferred;;
<lars9>
thanks
<sgnb>
lars9: those are declarations of parametrized abstract types
ftrvxmtrx has quit [Ping timeout: 240 seconds]
smerz has quit [Quit: Ex-Chat]
ftrvxmtrx has joined #ocaml
seafood has quit [Quit: seafood]
ulfdoz has joined #ocaml
ikaros has joined #ocaml
orion1010 has quit [Read error: Connection reset by peer]
LeNsTR has quit [Quit: LeNsTR]
<adrien>
working with svg was quite nice for drawing, of course, learning a new spec isn't always a lot of fun and typos are easy and there are no warnings but it was fun =)
jm_ocaml has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 276 seconds]
ftrvxmtrx has joined #ocaml
<edwin>
gildor: OASISLexer.mll | ":" {SEMICOLON}
<edwin>
gildor: that is not a semicolon ;)
jm_ocaml has quit [Ping timeout: 240 seconds]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
middayc has joined #ocaml
accel has quit [Quit: leaving]
jm_ocaml has joined #ocaml
boscop__ has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
Yoric has quit [Quit: Yoric]
<thelema>
kaustuv: new modules pushed to batteries - one typo found in batdeque.mli
lpereira has joined #ocaml
<gildor>
edwin: indeed, this is a colon ?
<gildor>
edwin: bug report ?
<gildor>
edwin: and OASISLexer.mll is in fact not used
<thelema>
yes, this is a colon.
<gildor>
edwin: ok, fix it in the source
<edwin>
gildor: not worth a bugreport, just something I noticed :D
<edwin>
by accident
<mfp>
ocamlopt punished me for getting cocky > This expression has type Ty.db Stmt.t but an expression was expected of type 'a Stmt.t The type constructor Ty.db would escape its scope :-/
<mfp>
was there a std way to approach this kind of pbs?
ygrek has quit [Remote host closed the connection]
<mrvn>
How does the code look like?
ygrek has joined #ocaml
<mfp>
I had something like module Stmt = struct type 'a t = { ...; x : 'a } end followed by module rec Ty = sig type db = { ...; tbl : db Stmt.t WT.t; } end = Ty and WT : Weak.S with type data = Ty.db Stmt.t = Weak.Make(struct type t = Ty.db Stmt.t ... end)
<mfp>
then when I tried to get stmt.x (to obtain the db), I got the above error
<mfp>
solved by removing recursion, but wonder what the forceful approach would look like
<mrvn>
I think with module rec you sometimes need to add the module path.
<mfp>
was getting conceited after the module rec X : sig ... end = X trick, so ocamlopt hit me on the shoulder
<thelema>
:)
<mfp>
mrvn: as in, db = { ... tbl : Ty.db Stmt.t WT.t; } ? (instead of db Stmt.t WT.t)
<mrvn>
mfp: if that removed the problem then yes
asmanur_ has joined #ocaml
asmanur has quit [Ping timeout: 246 seconds]
smerz has joined #ocaml
grettke has joined #ocaml
grettke has quit []
lars9 has quit [Remote host closed the connection]
yezariaely has joined #ocaml
yezariaely has left #ocaml []
ikaros has quit [Quit: Leave the magic to Houdini]
lpereira has quit [Quit: Leaving.]
derdon has joined #ocaml
<derdon>
hello
<orbitz>
hi
<thelema>
hi
<derdon>
how can I convert a char to a string?
<thelema>
String.make 1 c
<derdon>
ok, I thought there would be a cleaner solution
<orbitz>
let string_of_char = String.make 1
<thelema>
let string_of_char = String.make 1 in ...
<thelema>
:)
<orbitz>
hah
<derdon>
ah, this is good
<derdon>
but why is this function not in the stdlib?
<orbitz>
The stdlib is increidbly sparse
<orbitz>
I use Jane St Core
<orbitz>
i'm not sure if hta tis a good choice but so far I've ofun dit good
<thelema>
I use batteries
<thelema>
BatString.of_char
middayc_ has joined #ocaml
<thelema>
orbitz: I look forward to a core user trying out batteries and telling me what's missing
<derdon>
thelema: yes, the problem is that the official stdlib is not maintained by the community
<thelema>
not that I can't do a module diff myself, but the things that actually get used...
<thelema>
derdon: neither is the compiler.
<derdon>
thelema: yes
<derdon>
thelema: maybe there will be a bored team, anytime…
<orbitz>
thelema: I don't know Core well enough to compare them (yet), but I'm doing more an dmore projects in ocaml so hopefully I'll be able ot give a good comparison in the future
<thelema>
orbitz: can you point out the core modules you happen to use the most?
middayc has quit [Ping timeout: 240 seconds]
<orbitz>
thelema: i can tell you the major thing that sucks about core is it's really onlyt ested on Linux. They rewrote some process backend ustff in C and it doesn't seem tow ork on my mac (have not tested latest codebase though)
<orbitz>
thelema: For what I'm doing I use Core_extended.Std.String, Core_extended.Shell the most. I also like that things like List have been rewritten to require labels
<thelema>
yes, I've been thinking a lot about labels too, and think they're a good thing. But I think backwards compatibility is another good thing.
<orbitz>
thelema: I find the excessive use of labels very helpful
<thelema>
I just want to be able to reorder my maps and folds
<thelema>
and having extra "documentation" isn't bad
<orbitz>
I can never remember what order things come in with List.fold_left
<orbitz>
Core requird ~f and ~init
<thelema>
orbitz: yup.
<orbitz>
backwards compatibility is nice, but at the same time I think the fact that Core doesn't care about it makest he experience more conherent
<gildor>
there is more information about cryptokit (because of _oasis file presence)
middayc has joined #ocaml
middayc_ has quit [Ping timeout: 240 seconds]
cyanure has joined #ocaml
joewilliams_away is now known as joewilliams
almaisan-away has joined #ocaml
almaisan-away is now known as al-maisan
al-maisan has left #ocaml []
smerz has quit [Remote host closed the connection]
Snark has quit [Quit: Ex-Chat]
myu2 has quit [Remote host closed the connection]
joewilliams is now known as joewilliams_away
cyanure has quit [Ping timeout: 272 seconds]
gildor has quit [Ping timeout: 276 seconds]
gildor has joined #ocaml
jm_ocaml has quit [Ping timeout: 255 seconds]
jm_ocaml has joined #ocaml
ikaros has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 264 seconds]
drunK has joined #ocaml
ftrvxmtrx has joined #ocaml
edwin has quit [Remote host closed the connection]
eelte has joined #ocaml
coucou747 has quit [Read error: Operation timed out]
ygrek has quit [Remote host closed the connection]
lamawithonel has joined #ocaml
cyanure has joined #ocaml
cyanure has quit [Remote host closed the connection]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
ccasin has joined #ocaml
Yoric has quit [Quit: Yoric]
lamawithonel has quit [Ping timeout: 255 seconds]
<ccasin>
is it my imagination, or does the "set_text_size" function in the Graphics module of the stdlib do nothing?
jm_ocaml has quit [Ping timeout: 240 seconds]
<derdon>
ccasin: UTSL ;)
<thelema>
ccasin: yes, it does nothing, confirmed
<adrien>
font handling isn't trivial, especially now, lots of things have changed in the past years
<ccasin>
yes, thanks all
<ccasin>
"implementation dependent" indeed
<adrien>
you could use cairo/pango instead (or svg :P )
<derdon>
or PPM
<ccasin>
yeah, I have to use only the stdlib for this application, (being distributed on all platforms to introductory CS students)
<ccasin>
thanks though
<thelema>
ccasin: ? ocaml is pretty statically linked
<ccasin>
the source has to compile on all platforms, I mean
<ccasin>
and I don't want to troubleshoot 150 students installing graphics libraries :)
<ccasin>
it's no big deal though, the text will just come in one size
<derdon>
ccasin: you could ship a Makefile, so the students only have to enter one simple command
<ccasin>
alas, I am also constrained by an IDE :)
<adrien>
well, pango and cairo are very widely available, and as for svg, as long as you don't use animations ( ='( ), it'll work pretty much everywhere (I don't know what you're doing with Graphics but svg might fit)
<ccasin>
If I depend on any dev libraries I will have to help the 100 students on windows install them. On balance, having ugly buttons is a win :)
<ccasin>
unless you are saying there is svg support in the stdlib?
ikaros has quit [Quit: Leave the magic to Houdini]
doodo has joined #ocaml
<thelema>
ccasin: svg is a text format, you can output it straightforwardly from stdlib
<ccasin>
thelema: I confess I'm a little confused. I'm writing a little GUI that must compile and run on the students' machines. The stdlib has support for displaying svg graphics in this gui?
<adrien>
it's hard to tell without knowing everything: currently, SVG is probably best viewed in browsers, if you need to react to events, that won't be great probably
<adrien>
lablgtk is a decent alternative and not hard to get
<adrien>
(but there is still a segfault in libgthread ='( )
<ccasin>
Yeah, these are fine ideas. But the GUI must run as an ocaml program and even lablgtk is too much of a dependency. It's no big deal, though, I'm OK with the ugly little thing I can hack up the Graphics module
<ccasin>
even with just one text size :)
<doodo>
I am trying to write a function that uses pattern matching. The function takes an list. If the first 2 elements of the list are different, they get swapped. If they are the same, nothing happens. can i do something like: let swap x = match x with [] -> [] | [a] -> [] | [a;b] -> [b;a] if a != b ???
<adrien>
you can use the "when" extension: | 'pattern' when 'cond' -> 'do'
<doodo>
what if my list is an arbitrary lenght?
<adrien>
whalso, you probably want to use '| a :: b :: t -> ' instead of '| [a; b] ->', that will keep the end of the list
ulfdoz has quit [Ping timeout: 240 seconds]
<adrien>
so: | a :: b :: t when a <> b -> b :: a :: t
<adrien>
| l -> l
<doodo>
what does | 1->1 do? is that just the anything goes matching pattern?
<adrien>
'l', not '1': first letter of 'list', and yes: it will match anything and will return that anything
<adrien>
well, anything not previously matched
<doodo>
ah ok thanks
* derdon
loves pattern matching :)
<derdon>
it's a wonderful invention!
<doodo>
i am completely new to ocaml and functional programming so i have no idea what i am doing
<adrien>
everyday I'm more and more wondering how things in our world can work: with so many approximations and "I'm sure it'll work" things
<doodo>
what amazes me is some things we deal with daily whose size of complexity is larger than the number of atoms in the know universe
<dark>
a literal matches only itself
<doodo>
how would you access only odd elements in a list?
<dark>
List.filter (fun x -> x mod 2 = 1) list
<dark>
that is, if odd is a function that recognizes odd numbers, List.filter odd list returns all odd numbers of list
<dark>
# List.filter (fun x -> x mod 2 = 1) [0; 1; 2; 3; 4; 5];;
<dark>
- : int list = [1; 3; 5]
<thelema>
doodo: what dark is saying would produce a new list with only the odd elements
<doodo>
what about doing it recursively
<dark>
it does it recursively o.o you just need to write List.filter, it's a recursive function; then you will never need to write a recursion of this form again
<doodo>
what about using split?
<dark>
anyway, using 'bare recursion' it would be let filter_odd = function [] -> [] | a::r -> if a mod 2 = 1 then a :: filter_odd r else filter_odd r
<dark>
oh, let rec filter_odd = ..
<dark>
then filter_odd list
<dark>
don't know how to use split for that o.o
<dark>
# let rec filter_odd = function [] -> [] | a::r -> if a mod 2 = 1 then a :: filter_odd r else filter_odd r;;
<dark>
val filter_odd : int list -> int list = <fun>
<dark>
# filter_odd [0; 1; 2; 3; 4; 5];;
<dark>
- : int list = [1; 3; 5]
<dark>
doodo, you meant before, how to access odd numbers in the pattern match?
<doodo>
i want to add up the integers in the odd position of the list
<dark>
it would be like match 5 with x when x mod 2 = 1 -> "number is odd" | x -> "number is not odd"
<dark>
oh
LeNsTR has joined #ocaml
<dark>
odd _position_?
<doodo>
yeah
<dark>
like [1; 2; 4] add 1 and 4?
<doodo>
yeah, it should return 1 + 4
<dark>
i am thinking in how to do this with fold
<doodo>
nvm i figured it out
<dark>
# let rec add_odd = function [] -> 0 | a::[] -> a | a::b::r -> a + add_odd r;;
<dark>
val add_odd : int list -> int = <fun>
<dark>
# add_odd [1; 2; 4];;
<dark>
- : int = 5
<dark>
ok
<doodo>
let rec split lis = match lis with [] -> ([],[]) | [x] -> ([x],[]) | (x::y::xs) -> let (lis1,lis2) = split xs in (x::lis1, y::lis2)
<thelema>
doodo: that'll work - just work on one list
<doodo>
right, but how do i use this function with my function that takes the sum of the list?
<thelema>
let evens,odds = split lis in ...
Modius has quit [Quit: "Object-oriented design" is an oxymoron]
<dark>
oh nice :)
<dark>
i was thinking in a fold that did a little flag to mark if i'm in an even or odd element
<doodo>
so 'in
<doodo>
is to denote function parameters?
<dark>
in? where? no, it's to denote sub definitions
<thelema>
let sum_odds l = List.fold_left (fun x (o,a) -> if o then (false, x+a) else (true,a)) (true,0) l |> snd
<dark>
|>? from batteries?
<thelema>
dark: yes, let (|>) x f = f x
<dark>
let k.. = let sub.. = .. in def.. means that the definition of k is def.., but sub.. can be used there, doodo
<dark>
like let a = let b = 1 in b + 5, this is the same aslet a = 1 + 5