sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
bluestorm_ has quit ["Konversation terminated!"]
mnemonic has quit ["leaving"]
Submarine has joined #ocaml
postalchris has joined #ocaml
postalchris has quit [Client Quit]
Submarine has quit [Remote closed the connection]
johnnowak has joined #ocaml
pants1 has joined #ocaml
pstickne has quit [Read error: 104 (Connection reset by peer)]
pstickne has joined #ocaml
pstickne has quit [Read error: 104 (Connection reset by peer)]
<mbishop> So did you guys see the message one fa.ocaml about Pragmatic Programmer being willing to publish an OCaml book?
pstickne has joined #ocaml
er has quit ["Leaving"]
mbishop has quit ["Leaving"]
mbishop has joined #ocaml
shawn has joined #ocaml
pants1 has quit [Remote closed the connection]
slowriot has joined #ocaml
b00t has joined #ocaml
johnnowak has quit []
slowriot has quit []
Riesz has quit ["Leaving.."]
Smergo_ has quit [Read error: 145 (Connection timed out)]
david_koontz has joined #ocaml
Smerdyakov has quit [Client Quit]
slipstream-- has quit [Read error: 60 (Operation timed out)]
slipstream has joined #ocaml
pstickne has quit ["Leaving"]
pstickne has joined #ocaml
Smergo has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
b00t has quit ["Leaving"]
b00t has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
diffbavis has quit [Read error: 131 (Connection reset by peer)]
shawn has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
love-pingoo has joined #ocaml
jlouis has quit [Remote closed the connection]
<flux-> hmh, at about now I wouldn't mind cross-file recursive modules..
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
ozzloy has quit [Remote closed the connection]
b00t has quit [Remote closed the connection]
chequers has joined #ocaml
<chequers> does anyone have any idea about how long the ocaml compilation process should take from freebsd ports compared to 'normal'?
<chequers> mines been running for far longer than I would have expected
<love-pingoo> compilation of ocaml can be quite long, as it's bootstrapped
<chequers> it's partially written in ocaml itself?
<jacobian> The first time I compiled CMUCL it took 12 hours
<chequers> ahh, just finished
<chequers> took me about 45mins or so compared to <20 for php and python
<jacobian> yeah those are pretty different beasts
<chequers> ok, well it's compiling latex ok, so no dramas
<love-pingoo> chequers: it's entirely written in OCaml
<love-pingoo> the distribution includes a binary for recompiling the compiler, I believe
chequers has left #ocaml []
zygomatik has joined #ocaml
<zygomatik> Hi i'd like a function find_alli : 'a -> bool -> 'a array -> int array that gives all indices where a predicate is true. But I'm sure it already exists one way or another but I can't find it. I think of
<zygomatik> let find_alli pred a =
<zygomatik> let a = Array.mapi (fun i e -> (e,i)) a in
<zygomatik> Array.map (fun x-> snd x) (Array.filter (fun x -> pred (fst x)) a)
<zygomatik> But in a deforested version
<zygomatik> any clue ?
<zygomatik> dont tell me there is no more standard way to do this
Smerdyakov has joined #ocaml
descender has quit [Remote closed the connection]
descender has joined #ocaml
rillig has joined #ocaml
diffbavis has joined #ocaml
pango has quit [Remote closed the connection]
smimp has joined #ocaml
love-pingoo has quit ["Leaving"]
pango has joined #ocaml
<zygomatik> let me rephrase my question what is the standard way to get all indices of an array where a predicate is true
<zygomatik> i'm sure that there is better than
<zygomatik> Array.map (fun x-> snd x) (Array.filter (fun x -> pred (fst x)) a)
<zygomatik> oups
<zygomatik> let find_alli pred a =
<zygomatik> let a = Array.mapi (fun i e -> (e,i)) a in
<zygomatik> Array.map (fun x-> snd x) (Array.filter (fun x -> pred (fst x)) a)
<zygomatik> everyone is sleeping or my question is that silly ?
<zygomatik> both ?
<zygomatik> :)
benny has joined #ocaml
postalchris has joined #ocaml
benny_ has quit [Read error: 145 (Connection timed out)]
jlouis has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Remote closed the connection]
bluestorm_ has joined #ocaml
smimou has joined #ocaml
Smergo has quit [Read error: 60 (Operation timed out)]
Smergo has joined #ocaml
jlouis_ has quit ["Leaving"]
jlouis has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
<flux-> smerdyakov, btw, thanks for the suggestion on using class types, they seem to fit my needs
<flux-> albeit it didn't directly solve the problem I had, I'm still using recursive modules
<flux-> like: module rec A : sig class type a = object method foo : B.t end end = struct class type a = object method foo : B.t end end and B : sig type t = { foo : unit -> A.t list } end struct type t = { foo : unit -> A.t list } end
<flux-> lots of repetition, though :(
<flux-> also I think I should replace B.t with a class, although it doesn't use inheritance or such concepts. would that allow to write recursive class definitions more easily?
<flux-> zygomatik, I don't think there's any other way, such as something provided by the standard library, except to do it yourself.
<flux-> zygomatik, maybe more faster could be something that involves using mutable values..
<flux-> that way you could use Array.iteri to construct the list directly
<flux-> (you'd need to reverse the list, though, if you'd the list to be in ascending order)
<flux-> +like
love-pingoo has joined #ocaml
ikaros has quit [Read error: 60 (Operation timed out)]
ikaros has joined #ocaml
Submarine has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
ozzloy has joined #ocaml
diffbavis has quit [Read error: 54 (Connection reset by peer)]
diffbavis has joined #ocaml
pi-meson has joined #ocaml
<zygomatik> flux-, isnt there a way to use higher order functions to deforest the previous function
<zygomatik> and keep the values unmutables ?
<zygomatik> I dont know how to do it but maybe there is
<pi-meson> What's the best way to install ocaml modules if you don't have root? I know python makes it easy to install to your homedir and set your path, but I'm having trouble finding if there is a similar mechanism for ocaml
<zygomatik> it's strange though as it is a quite general feature one could ask to get the indices where a predicate is true
shawn has joined #ocaml
<zygomatik> a bit like v[v==w] in matlab
<Smerdyakov> zygomatik, I would like to try answering your question, but it doesn't make sense to me, as I don't know Matlab.
<zygomatik> Smerdyakov, I asked what would be the straighest way to implement a function that takes a list, or an array, and return the indices where a predicate is true
<Smerdyakov> zygomatik, not sure what you mean by "straightest," but the list version is already in the standard library.
<zygomatik> something like find_alli
<Smerdyakov> Ooooh.
<zygomatik> Smerdyakov, I'm not aware of it
<zygomatik> tell me how to do with lists
<Smerdyakov> Not to return the indices, but to return the sublist of elements satisfying the predicate.
<Smerdyakov> You really want the numeric indices?
<zygomatik> this is not the same
<Smerdyakov> I know it's not the same. Misread the question.
<zygomatik> yes this is what i'm asking
<zygomatik> I proposed something like
<zygomatik> let find_alli pred a =
<zygomatik> let a = Array.mapi (fun i e -> (e,i)) a in
<zygomatik> Array.map (fun x-> snd x) (Array.filter (fun x -> pred (fst x)) a)
<Smerdyakov> Ew. I would just write a new recursive function for it.
<zygomatik> but i don't find it very convenient as it uses three arrays in memory
<Smerdyakov> Why not return a list instead of an array, also?
<zygomatik> the one for a, the one for filter
<zygomatik> yes whatever
<zygomatik> and the last one
<Smerdyakov> Then it's very easy to do by defining a new recursive function.
<zygomatik> ok tell me
<zygomatik> i see if you use the list h::q match for lists
<zygomatik> yes I agree
<Smerdyakov> let inds p = let rec f n = function [] -> [] | h :: t -> if p h then n :: f (n+1) t else f (n+1) in f 0
<Smerdyakov> (With a 't' added there in the 2nd case)
<zygomatik> yes right
<zygomatik> and for array the same but with a for loop I guess ?
<Smerdyakov> I never use loops, and I advise others never to use them.
<zygomatik> but there is no h::t equivalent for array, no ?
<Smerdyakov> So?
<zygomatik> how to avoid looping explicitely ?
<Smerdyakov> Recursive functions
<zygomatik> so I guess my question is how to decapitate an array efficiently ?
<Smerdyakov> That's between the compiler and you, but you can always dereference the elements individually. I'm assuming you know that and are asking compiler-specific questions related to what kind of object code is generated?
<zygomatik> no I'm just asking how to decapitate an array like a list
<zygomatik> efficiently
<Smerdyakov> What does "efficiently" mean? It must be a compiler-specific question.
<zygomatik> sorry if my question does not make sense, i'm a beginner, i guess my question is "could you write the function you just wrote for lists but for arrays" ?
<Smerdyakov> Yes, but you wouldn't want to deconstruct arrays in that way, since copying an array is not constant-time like "copying" a list is.
<zygomatik> that is precisely my point
<Smerdyakov> Have you done programming before?
<zygomatik> a little
<zygomatik> how is that related ?
<Smerdyakov> OK... I have been assuming that you are asking questions about OCaml, but it sounds like you don't understand how to write this program even in another language. Or am I wrong?
<zygomatik> anyway thanks for your answer with lists
<Smerdyakov> I'm interested in helping you, but I need the answer to my last question to do that.
<Smerdyakov> ...or you could just be pouty about it and sulk off.
Smerdyakov has quit ["Leaving"]
<zygomatik> ?
<love-pingoo> zygomatik: forget about him, and don't worry: he's not representative of the people here
<zygomatik> it is ok i don't feel insulted
<zygomatik> let array_find_alli pred a =
<zygomatik> let res = ref [||] in
<zygomatik> Array.iteri (fun i e -> if pred e then res := Array.append !res [|i|]) a
<zygomatik> is it something like that you had in mind flux- ?
<zygomatik> love-pingoo, but I'd be very glad to understand if it is possible to code the recursive function he wrote for lists recursively with arrays
pi-meson has quit ["Leaving"]
<zygomatik> perhaps this question does not make sense though
<love-pingoo> zygomatik: no it's not really possible in general
<love-pingoo> you cannot efficiently get the tail of an array
<zygomatik> ok thank you very much for this very clear answer ;)
<zygomatik> and for helping a noob too :) good night
zygomatik has left #ocaml []
malc_ has joined #ocaml
Submarine has quit ["Leaving"]
love-pingoo has quit ["Connection reset by pear"]
postalchris has quit ["Leaving."]
smimp has quit ["Lost terminal"]
mnemonic has joined #ocaml
smimou has quit ["bli"]
david_koontz has quit ["Leaving"]