Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: bfb3ea39ea
Fetching contributors…

Cannot retrieve contributors at this time

143 lines (142 sloc) 11.004 kb
03:51:25 <jimi_hendrix> i assume the typical way to iterate through a list is to pattern match head :: tail and then recurse with tail?
03:52:23 <_habnabit> there's also List.iter, and List.map, and so on.
03:53:44 <jimi_hendrix> ok
03:54:13 <jimi_hendrix> also, what is the recommended introduction to ocaml? the manual seems to not go into much depth in some areas
03:54:29 <jimi_hendrix> (it only mentions tuples without showing their syntax, afaik)
05:39:33 <flux> jimi_hendrix, Introduction to Objective Caml ebook (free) by Jason Hickey seems decent
05:40:16 <flux> jimi_hendrix, there is also the syntax part of the manual, but that's quite difficult reading..
07:44:37 <emias> ,
07:51:14 <flux> indeed, ,.
08:06:10 <f[x]> gildor -> https://forge.ocamlcore.org/forum/forum.php?forum_id=810
09:38:45 <gildor> f[x]: fixed
09:39:31 <f[x]> thx
14:41:37 <robert[]> hello
14:41:50 <robert[]> I've just wondered about Ocaml for GUI programs on GNU/Linux
14:42:13 <thelema> It's possible - many people use lablgtk2
14:42:46 <robert[]> do you think it is a great idea
14:42:52 <adrien> "great"?
14:42:53 <robert[]> Let me put it this way
14:43:02 <robert[]> I have a lot of bad luck with computers :)
14:43:14 <robert[]> I would probably best use C++ Or pyhthon for the least chance of problems
14:43:21 <robert[]> but it is a lot nicer to program in Ocaml
14:43:37 <robert[]> so I couldn't decide what should I use
14:43:40 <adrien> imho, ocaml/lablgtk beats C++/Qt hands down
14:44:05 <robert[]> it's just on here http://www.gtk.org/language-bindings.php
14:44:09 <robert[]> it's a few version away
14:44:12 <robert[]> maybe doesn't matter
14:44:34 <adrien> if you're missing some API, ask me and I'll add it
14:44:50 <adrien> well, my goal is to catch up on some things but I'll prioritize it
14:44:59 <adrien> (I recently became a commiter of lablgtk2)
14:45:03 <robert[]> oh cool
14:45:21 <rwmjones> robert[]: I've written a few largish programs using lablgtk2, and it's fine for that
14:45:24 <rwmjones> eg:
14:45:25 <robert[]> thanks very much!!
14:45:26 <adrien> but chances are you won't be missing anything
14:45:26 <rwmjones> guestfs-browser
14:45:37 <robert[]> I just want to make a simple board game
14:45:41 <robert[]> I think ocaml is really nice to use
14:45:45 <robert[]> so I will try my best
14:46:01 <adrien> and read and grep the "examples" folder in lablgtk2's sources
14:46:06 <robert[]> by the way, do you have a good Prolog or similar in ocaml?
14:46:09 <rwmjones> http://git.annexia.org/?p=guestfs-browser.git
14:46:22 <robert[]> this is great thanks I will look at these examples
14:47:20 <adrien> but for lablgtk2, read the tutorial carefully, especially the first chapters, and the API of lablgtk2 closely follows the one of the C library
14:48:46 <adrien> (and for drawing and receiving events, you'll want to look at #misc and #event methods iirc)
14:48:52 <adrien> (this is for later on)
15:08:36 <robert[]> sorry but do I want lablgtk or lablgtk2? :S
15:08:45 <thelema> 2
15:08:51 <robert[]> thanks
15:10:07 <robert[]> I get problems with the web browser
15:10:20 <thelema> robert[]: compiling the examples?
15:10:24 <robert[]> it says stuff about ocamlcore being unsecure
15:10:30 <robert[]> false security cerfificate
15:10:58 <thelema> yes, gildor tried fixing that, but it's still funny
15:11:17 <thelema> that's a known problem with ocamlcore at the moment.
15:11:22 <robert[]> git clone https://forge.ocamlcore.org/anonscm/git/lablgtk/lablgtk.git
15:11:28 <robert[]> this is fine? :)
15:11:32 <adrien> yes
15:11:41 <adrien> hmmm
15:11:46 <adrien> why not take the releases?
15:11:53 <robert[]> hmm
15:12:59 <robert[]> great
15:13:48 <adrien> which OS/distro are you on?
15:46:52 <jimi_hendrix> can someone please tell me why I am getting an error with my intersects method here? the error is in a comment at the bottom of the paste. http://pastebin.com/Gj0MHVXA
15:47:11 <jimi_hendrix> i have tried various things to fix the typing error, but none have worked
15:47:31 <thelema> jimi_hendrix: what's the line number of the error?
15:47:48 <robert[]> method virtual intersects : ray -> float * ray_result
15:47:53 <robert[]> method intersects (ray:ray) (dist:float)
15:47:59 <robert[]> this is a conflict
15:48:01 <thelema> ok, there's an incompatibility between L43 and L49
15:48:01 <jimi_hendrix> ah
15:48:02 <jimi_hendrix> thanks
15:48:46 <jimi_hendrix> that was it robert[]
15:49:12 <thelema> jimi_hendrix: btw, you have a typo on L4
15:49:36 <jimi_hendrix> thelema, fixed
20:16:23 <abdallah> I am using rectangular 'a matrix, should I use the simple 'a array array or linearize it to 'a array?
20:18:02 <robert[]> I think the best way to work is such that it's impossible to tell the difference
20:18:21 <Anarchos> abdallah depends on what you want to do with the type !
20:18:41 <robert[]> I mean programming in such a way that the definition (being 'a array array or 'a array) cannot be found (and therefore it could be changed etc..)
20:19:08 <robert[]> I don't know if I made sense...
20:19:35 <abdallah> Yeah, sure. It's already encapsulated in its own module, but I'm wondering for the implementation of this module.
20:20:58 <abdallah> The element type is a three valued enum and the size of the matrix can be assumed no to go over 10x10 (probably not over 6x6 but I am not sure).
20:21:50 <abdallah> So I suppose in the end, I'll have to use a bitboard but I feel like it's way less readable.
20:25:11 <dancannon> Hi, How could I get this code to work? https://gist.github.com/1276406
20:25:58 <robert[]> checkZero ls ret should be checkZero tl ret
20:26:08 <robert[]> otherwise the recursion will never terminate
20:26:17 <dancannon> Ah
20:26:26 <dancannon> Ooops
20:27:01 <dancannon> Sorry about that, I have been working for a while
20:27:04 <abdallah> Thanks for your answers.
20:27:26 <dancannon> I thought I had the syntax wrong. THanks
21:02:17 <thelema> abdallah: abstract your operations to make them readable. i.e. `get_bit board i j`
21:03:04 <thelema> abdallah: also, arrays of arrays are implemented with the first array holding pointers to the second array. If you want/need to avoid the indirection, you'll need to do the multiply-addressing yourself.
21:04:16 <thelema> abdallah: most likely, you'll be fine with a `enum array array`, as it'll fit within L1 cache easily
21:05:02 <abdallah> thelema: So if the matrix is small, the indirection is not much more costly than (i - 1) * m + (j - 1) ?
21:05:55 <thelema> if you use 0-based array indexes, you can avoid the -1's
21:06:14 <thelema> I'm not sure the cost of a L1-cache hit on your platform
21:06:37 <thelema> http://stackoverflow.com/questions/4087280/approximate-cost-to-access-various-caches-and-main-memory
21:07:03 <thelema> according to this, L1 = ~4 cycles, so it'll be about the same as the math
21:07:26 <jimi_hendrix> another silly beginner question: i am trying to write a function without side effects but i cannot figure out a good way to do it. here is my psuedo-code for the function: http://pastebin.com/5kKEmuNX
21:07:58 <thelema> jimi_hendrix: Use List.fold_left
21:08:03 <abdallah> Ok. What is an approximate size of the L1-cache on a desktop computer ?
21:08:24 <jimi_hendrix> thelema, thanks for the tip
21:09:02 <thelema> abdallah: 64KB data + 64KB instructions
21:09:07 <thelema> per core
21:09:15 <abdallah> Ok, thanks a lot.
21:09:53 <thelema> jimi_hendrix: or if you're using batteries, you can use Enum.arg_min
21:10:19 <jimi_hendrix> thelema, whats that?
21:10:30 <thelema> jimi_hendrix: you might consider using `float option` for your return type of p.intersects
21:10:57 <jimi_hendrix> alright
21:11:19 <thelema> jimi_hendrix: batteries is an extended stdlib. Enum is its sequence type, and arg_min takes a function and an enum and returns the element of that enum that gives minimum value on that function
21:11:52 <jimi_hendrix> ok
21:11:57 <thelema> http://batteries.forge.ocamlcore.org/
21:12:31 <jimi_hendrix> thelema, i think i will go with the left fold for the experience
21:12:50 <thelema> jimi_hendrix: yes, better for learning
21:17:45 <rferranti> that's an unfortunate name, isn't it?
21:18:10 <jimi_hendrix> thelema, and then the function i pass to the fold will take two arguments, calls intersects and both of them, and returns the one with the lesser hit distance?
21:19:24 <thelema> jimi_hendrix: you could do that. You probably don't want to compute the distance repeatedly, so you could keep that with the closest object
21:20:40 <rgrinberg> is it usually expensive to call "of_enum"? for various collections?
21:20:45 <jimi_hendrix> thelema, what do you mean by that
21:20:47 <rgrinberg> like say a BatSet
21:20:56 <thelema> List.fold_left (fun (best_obj,best_dist as acc) obj -> match obj#intersects ray with Some d when d < best_dist -> (obj, d) | _ -> acc) ...
21:21:22 <thelema> rgrinberg: no more expensive than constructing the set some other way.
21:22:17 <rgrinberg> and turning stuff into an enum?
21:22:51 <thelema> rgrinberg: done lazily - depends on how much of the enum you consume
21:23:42 <rgrinberg> my general problem is that I would like to write functions that don't always depend on the data structure but on what kind of operations it supports. in f# I'd just always call Seq.map/filter or w/e and that would work on arrays, lists, etc. In haskell they have typeclasses. what to do in ocaml?
21:23:45 <thelema> There's definitely an overhead to enumerations, but it's just a constant factor over, say, an array
21:24:23 <thelema> rgrinberg: use functors in ocaml for that.
21:25:24 <jimi_hendrix> thelema, ah
21:25:39 <jimi_hendrix> thelema, is the fun keyword the same as the function keyword?
21:25:57 <thelema> jimi_hendrix: not quite. "function" corresponds roughly to "fun x -> match x with"
21:26:14 <jimi_hendrix> ah
21:26:28 <rgrinberg> thelema: ok ill go read about them, see if i make some progress.
21:28:06 <Anarchos> jimi_hendrix fun keyword accepts multiple arguments : let f = fun x y ->y
21:28:21 <jimi_hendrix> Anarchos, ok
21:30:14 <everyonemines> Is there an overhead to passing pairs between functions, or matching against (x,y) ? I mean, does that add a level of pointer dereferencing?
21:30:45 <thelema> everyonemines: sometimes, but the ocaml compiler is quite good at getting rid of it when the pair isn't used as a single value.
21:33:42 <jimi_hendrix> thelema, anyway, thanks for all the help
21:33:58 <thelema> jimi_hendrix: n/p.
21:36:14 <jimi_hendrix> thelema, also, what would i pass to the folding function for best_obj part of the tuple? the best_distance part would obviously be the maximum distance.
21:50:19 <everyonemines> thelema: So just avoid using "foo as (x,y)" and it gets optimized out?
22:11:43 <devinus> does ocaml have something akin to rvm for ruby or pythonbrew for python?
23:12:05 <everyonemines> devinus: godi
Jump to Line
Something went wrong with that request. Please try again.