mfp changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.11.2 released | Inscription for OCaml Meeting 2010 is opened http://wiki.cocan.org/events/europe/ocamlmeetingparis2010
ikaros_ has joined #ocaml
pimmhogeling has quit [Ping timeout: 265 seconds]
ikaros_ has quit [Ping timeout: 260 seconds]
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
julm has quit [Quit: fuck openssl, apache and readline]
julm has joined #ocaml
Amorphous has quit [Ping timeout: 252 seconds]
pimmhogeling has joined #ocaml
krankkatze has quit [Remote host closed the connection]
mbishop has quit [Ping timeout: 265 seconds]
mbishop has joined #ocaml
Amorphous has joined #ocaml
slash_ has quit [Quit: Lost terminal]
CcSsNET has joined #ocaml
tmaedaZ is now known as tmaeda
avsm has joined #ocaml
MURBMURB has joined #ocaml
MURBMURB has left #ocaml []
pimmhogeling has quit [Ping timeout: 265 seconds]
tmaeda is now known as tmaedaZ
yangsx has joined #ocaml
mfp has quit [Ping timeout: 252 seconds]
bzzbzz has quit [Quit: leaving]
_unK has quit [Remote host closed the connection]
mfp has joined #ocaml
Jedai has quit [Ping timeout: 246 seconds]
Jedai has joined #ocaml
brooksbp_ has joined #ocaml
brooksbp has quit [Ping timeout: 276 seconds]
avsm has quit [Quit: Leaving.]
Guest95631 has quit [Ping timeout: 260 seconds]
ned has joined #ocaml
ned is now known as Guest80479
enthymeme has joined #ocaml
joewilliams_away is now known as joewilliams
myu2 has joined #ocaml
Guest80479 has quit [*.net *.split]
mrvn has quit [*.net *.split]
thieusoai has quit [*.net *.split]
quelqun_dautre has quit [*.net *.split]
brendan has quit [*.net *.split]
flux has quit [*.net *.split]
yakischloba has quit [*.net *.split]
diml has quit [*.net *.split]
noj has quit [*.net *.split]
gildor has quit [*.net *.split]
mfp has quit [*.net *.split]
mbishop has quit [*.net *.split]
Camarade_Tux has quit [*.net *.split]
sfuentes has quit [*.net *.split]
TaXules has quit [*.net *.split]
dmarkey has quit [*.net *.split]
fremo_ has quit [*.net *.split]
fraggle_ has quit [*.net *.split]
nimred has quit [*.net *.split]
schme has quit [*.net *.split]
munga has quit [*.net *.split]
xevz has quit [*.net *.split]
deavid has quit [*.net *.split]
Ori_B has quit [*.net *.split]
srcerer has quit [*.net *.split]
mattam has quit [*.net *.split]
Tianon has quit [*.net *.split]
bitbckt has quit [*.net *.split]
svenl has quit [*.net *.split]
enthymeme has quit [*.net *.split]
Amorphous has quit [*.net *.split]
rbancroft has quit [*.net *.split]
det has quit [*.net *.split]
ski has quit [*.net *.split]
patronus has quit [*.net *.split]
bjorkintosh has quit [*.net *.split]
orbitz_ has quit [*.net *.split]
shr3kst3r has quit [*.net *.split]
M| has quit [*.net *.split]
infoe has quit [*.net *.split]
msteele_ has quit [*.net *.split]
brooksbp_ has quit [*.net *.split]
yangsx has quit [*.net *.split]
smimou has quit [*.net *.split]
Alpounet has quit [*.net *.split]
jonafan has quit [*.net *.split]
zhijie has quit [*.net *.split]
Asmadeus has quit [*.net *.split]
npouillard has quit [*.net *.split]
LionMadeOfLions has quit [*.net *.split]
myu2 has quit [*.net *.split]
emias has quit [*.net *.split]
Leonidas has quit [*.net *.split]
jlouis has quit [*.net *.split]
Jedai has quit [*.net *.split]
ztfw has quit [*.net *.split]
fabjan has quit [*.net *.split]
julm has quit [*.net *.split]
willb has quit [*.net *.split]
peper has quit [*.net *.split]
rwmjones has quit [*.net *.split]
mutewit has quit [*.net *.split]
jimmyb2187 has quit [*.net *.split]
pookleblinky has quit [*.net *.split]
sgnb has quit [*.net *.split]
myu2 has joined #ocaml
valross has joined #ocaml
mrvn has joined #ocaml
avsm has joined #ocaml
ulfdoz has joined #ocaml
Submarine has joined #ocaml
orbitz has joined #ocaml
Guest80479 has joined #ocaml
Jedai has joined #ocaml
mfp has joined #ocaml
yangsx has joined #ocaml
Amorphous has joined #ocaml
mbishop has joined #ocaml
julm has joined #ocaml
emias has joined #ocaml
rwmjones has joined #ocaml
Camarade_Tux has joined #ocaml
smimou has joined #ocaml
mutewit has joined #ocaml
jimmyb2187 has joined #ocaml
munga has joined #ocaml
rbancroft has joined #ocaml
Alpounet has joined #ocaml
willb has joined #ocaml
dmarkey has joined #ocaml
fremo_ has joined #ocaml
ztfw has joined #ocaml
deavid has joined #ocaml
fraggle_ has joined #ocaml
thieusoai has joined #ocaml
pookleblinky has joined #ocaml
jonafan has joined #ocaml
zhijie has joined #ocaml
quelqun_dautre has joined #ocaml
sfuentes has joined #ocaml
diml has joined #ocaml
sgnb has joined #ocaml
nimred has joined #ocaml
shr3kst3r has joined #ocaml
det has joined #ocaml
noj has joined #ocaml
ski has joined #ocaml
Asmadeus has joined #ocaml
brendan has joined #ocaml
flux has joined #ocaml
Leonidas has joined #ocaml
gildor has joined #ocaml
xevz has joined #ocaml
peper has joined #ocaml
npouillard has joined #ocaml
patronus has joined #ocaml
LionMadeOfLions has joined #ocaml
fabjan has joined #ocaml
M| has joined #ocaml
Ori_B has joined #ocaml
srcerer has joined #ocaml
schme has joined #ocaml
bitbckt has joined #ocaml
TaXules has joined #ocaml
infoe has joined #ocaml
mattam has joined #ocaml
Tianon has joined #ocaml
bjorkintosh has joined #ocaml
msteele_ has joined #ocaml
svenl has joined #ocaml
jlouis has joined #ocaml
sshc has quit [Max SendQ exceeded]
sshc has joined #ocaml
myu2 has quit [Ping timeout: 265 seconds]
myu2 has joined #ocaml
ulfdoz has quit [Ping timeout: 276 seconds]
ttamttam has joined #ocaml
oc13 has joined #ocaml
Yoric has joined #ocaml
Submarine has quit [Ping timeout: 248 seconds]
avsm has quit [Quit: Leaving.]
* mrvn is still puzzled why his Digest rewrite segfaults.
ski has quit [Ping timeout: 264 seconds]
<mrvn> What is wrong with http://paste.debian.net/64707/?
<mrvn> It somehow corrupts the memory causing segfaults in unrelated code.
ski has joined #ocaml
f[x] has joined #ocaml
<flux> are bigarrays guaranteed not to be moved by the gc?
<flux> but, I finally wrote a useful piece of code using ParserCo. not sure if it was worth it, though :).
<flux> maybe if a companion module for ParserCo was introduced, that would be more string-friendly (at present it doesn't know about strings)
<flux> and also such a module could support regular expressions as well
<flux> thelema, I believe ParserCo.none_of is broken, btw. it shouldn't have "not" in the front of the predicate function, should it?
<mrvn> flux: The ->data part is malloced so it should be outside the heap.
<flux> and b as well?
<mrvn> Plus the bigarray is only read so it shouldn't corrupt memory.
<mrvn> flux: hmm, no. I should get b->data before entering the blocking section
<mrvn> But again, only read access.
<flux> what if you remove the code from caml_md5_update_bigarray, does the problem still occur?
<flux> or at the very least, remove the call to caml_MD5Update
<mrvn> flux: caml_MD5Update writes to ctx but that is malloced by me and has sensical values. I will try but I can't think of anything that could be wrong there.
ikaros has joined #ocaml
<flux> mrvn, well, if the problem happens without caml_md5_update_bigarray doing any work, you should be able to narrow down the problem further
<mrvn> The problem doesn't happen if I don't call caml_md5_update_bigarray
<flux> well, it might just be that it doesn't torture gc enough
<flux> you're doing some work there now in the blocking section
<flux> I'm guessing the problem disappears if you take the blocking section away as well?
<mrvn> caml_md5_update_bigarray doesn't allocate so bno change in amount of GC work. But the enter/leave changes things.
<mrvn> think so.
yangsx has quit [Ping timeout: 260 seconds]
myu2 has quit [Remote host closed the connection]
jcaose has joined #ocaml
<mrvn> I just had a segfault with caml_MD5Update commented out.
myu2 has joined #ocaml
joewilliams is now known as joewilliams_away
pimmhogeling has joined #ocaml
_zack has joined #ocaml
ttamttam has quit [Quit: Leaving.]
pimmhogeling has quit [Remote host closed the connection]
<mrvn> ARRGGSSSS. Das problem scheint das "noalloc" zu sein.
<mrvn> aeh, ELANG.
<mrvn> Could it be that "noalloc" function MUST not use CAMLparam?
<flux> sounds like a real possibility
ttamttam has joined #ocaml
<mrvn> flux: Now I'm confused again. When I remove the CAMLparam2() I get segfaults.
<mrvn> Isn't that only needed when you allocate something, i.e. when the GC can be triggered?
<flux> thelema, how about if ParserCo.t also had a parameter for plural form? so one could have the current version ('a, 'a list) and then a character-specialization (char, string) or a unicode-specialization with (BatUTF8.t, Rope.t) ?
<flux> mrvn, I wonder if CAMLparam2 could allocate then something? look at its definition?
<mrvn> flux: CAMLparam2 creates a new root I believe.
<flux> thelema, such a plural form could be used for one_of, zero_plus, etc
<mrvn> http://paste.debian.net/64713/ That segfaults. If I use the comments then it works.
<flux> so is that a noalloc function?
<mrvn> It is but I haven't declared it as such.
<flux> so that crashes without caml_MD5Update as well?
<flux> caml_MD5Update seems to be plain C
<mrvn> it is.
<flux> so I guess it cannot cause such trouble
<mrvn> Can't get it to segfault again without it but that might just be a race condition
myu2 has quit [Remote host closed the connection]
<mrvn> But what does calling CAMLparam2() change? The GC can't possibly run between the start of the function and the caml_enter_blocking_section(). And after that no ocaml values are used.
<flux> btw, have you hooked gc alarm?
<flux> so produce output when gc is called
<mrvn> no
<mrvn> I turned up Gc debugging and I see lots of GC activity.
myu2 has joined #ocaml
<flux> crashes nicely for me as well
<mrvn> comment in the CAML_param2 and CAMLreturn and it works.
<flux> well, it stops crashing if I replace caml_MD5Update with { int c; for (c = 0; c <10000000; ++c); }
<mrvn> which would indicate that the ctx pointer overlaps with some other memory.
pimmhogeling has joined #ocaml
<flux> never thought of using Scanf that way, nice idea :)
<flux> (atleast for simple test programs)
<mrvn> Is there another function to convert string to int?
<flux> int_of_string
<mrvn> must have missed that
myu2 has quit [Remote host closed the connection]
<flux> I replaced caml_MD5Update with { struct MD5Context ctx2; caml_MD5Update(&ctx2, data, len); } and the problem goes away in this case as well
<mrvn> yeah. tried the same.
avsm has joined #ocaml
<flux> replacing data with a gloabl 100MB array didn't remove the problem
<flux> mrvn, did you notice that commenting free(ctx) solves the issue as well..
<mrvn> nope.
<mrvn> ==8510== Invalid read of size 4
<mrvn> ==8510== Address 0x5b6d3b4 is 4 bytes inside a block of size 88 free'd
<mrvn> Ahh, stupid me.
<flux> :)
<mrvn> Without CAMLparam2(context,...) nothing in foo.ml uses the context anymore. If the compiler makes the call tail recursive then the context is unreachable.
<mrvn> Could that be what happens?
<mrvn> wait, no. Can't be tail recursive because it i followed by "loop ()"
<mrvn> But somehow the GC finalizes the context before "update_bigarray context buf" returns.
myu2 has joined #ocaml
<flux> why would tail recursion affect anything?
<flux> isn't it sufficient that without CAMLparam2 nothing indeed is holding on to the context anymore, if the calling code doesn't
<mrvn> flux: because it ends the scope of variables
<mrvn> flux: but shouldn't the calling code hold on to it till the last command ?
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
<flux> true. removing decr num; from the calling thread (and making it infinite, thus holding context always) doesn't change a thing
<flux> mm no wait
<flux> you have let context = context () ni..
<flux> so wouldn't ocaml see that the context goes away when you call that function..
<flux> unless it hold on to it, which it doesn't
myu2 has quit [Remote host closed the connection]
<flux> if I put the context creation before the loop, the crash goes away
<mrvn> It must see that after the function call context is never used again so it drops it before calling with the assumption the called function will hold it itself?
<flux> as far ocaml is concerned, the lifetime of context ends to the call of update_bigarray
<mrvn> at the start of the call or at the end?
<flux> well, let's say the function is let foo a = call_some_other_fun ()
<flux> if you call foo context at some point and you don't hold on to context, it makes sense not to keep it aruond
<mrvn> but that is a tail call
<flux> let's say you have:
<flux> let foo a = perform_operations a; do_some_other_work ()
<flux> let rec loop () = let ctx = context () in foo ctx; loop ()
<flux> it makes sense to me that ctx is dropped after perform_operation a
<mrvn> but it is here dropped before.
<flux> it would not be if loop () still keeps a reference to it
<flux> well, from the ocaml's point of view it's the same?
<flux> it doesn't really consider what happens inside a function
<flux> let's consider two possibilities. first, loop does hold on to ctx: let rec loop () = let ctx = context () in foo ctx (* ok, loop holds on to ctx but drops it after call *); loop () -> in this case ctx cannot be dropped within foo (), because loop still holds on to it
<flux> on the other hand if it does drop it, it will be really dropped when foo drops its reference, which I think is what is preferable..
<mrvn> I just didn't think ocamlopt was that smart.
<flux> it's best to play by the rules instead of assuming ocaml isn't and never will be as smart :)
<mrvn> flux: The problem is that the caml_enter_blocking_section() means that some other thread can alloc (and trigger GC) in parallel. So the code really isn't "noalloc" anymore.
<mrvn> But I would never have guessed the problem is the finalizer being run too early.
<flux> funny how my log processing didn't reveal that
<flux> I guess the log message is produced too early
<flux> I processed the output to find uses of context after finalizing it
<mrvn> In most cases the next context just uses the same spot again.
<mrvn> I only spotted it in valgind when I added fprintf to the finalizer.
<flux> I scanned for all creations, uses and finalizations and ensured that a context must be created dusing usage
<flux> but I guess md5 takes such a long time that it can free it while it's processing
<mrvn> it does.
<mrvn> 7.3ms on my system for 1MB.
<mrvn> I still find it odd how it triggers random segfaults in other code and even causes the GC to report out of memory.
<mrvn> The GC and other code must malloc() stuff for a short while and get the same region the ctx was in before.
<mrvn> Lets see if it still all works when I put it back into the compiler itself.
<mrvn> flux: Doing this with bigarray and enter_blocking_section() does wonders for the core utilization.
<flux> mrvn, no wonder, 7.3ms is a decent amount of work
ikaros has quit [Quit: Leave the magic to Houdini]
<mrvn> Atom330 cpus aren't fast.
<mrvn> Takes 7.3s to md5sum 1GB with one core, 10s with 4 cores (added together).
<mrvn> Not quite sure why more threads take so much more time.
<flux> mrvn, btw, maybe you should add a lower-bound size that prevents enter/leave_blocking_section, so things like looping over single bytes doesn't yield insane locking overhead
<mrvn> flux: maybe. That needs to be measured I guess.
<mrvn> I don't expect someone to use single byte *big*arrays though.
<mrvn> mfp: How is that 3rd answere relevant?
<mfp> mrvn: it gives an upper bound for the cost of caml_leave_blocking_section
<mrvn> ahh, you mean because the example code measures the speed of the mutex.
<mfp> pthread_cond_signal
<flux> mrvn, well, a subarray might be small..
<mrvn> mfp: I guess with more threads it is more likely two threads want the mutex and need to wait for the condition. That could explain the increase in time
<mrvn> Is there a define for the systems pagesize?
<mfp> #include <unistd.h> sysconf(PAGESIZE)
<mrvn> I don't want to make a function call for every test.
<mrvn> Doesn't ocaml store that somewhere?
<mfp> (_SC_PAGESIZE in fact)
<mfp> got it
<mfp> <caml/config.h> -> Page_size
<mrvn> #define Page_log 12 /* A page is 4 kilobytes. */
<mrvn> stupid lower case :)
<mrvn> How does ocaml work on systems with variable pagesize? e.g. ppc.
<mrvn> ./foo 1 7.31s user 0.01s system 100% cpu 7.324 total
<mrvn> ./foo 2 8.54s user 0.02s system 193% cpu 4.419 total
<mrvn> ./foo 3 10.48s user 0.03s system 294% cpu 3.568 total
<mrvn> ./foo 4 11.14s user 0.06s system 365% cpu 3.067 total
<mrvn> ./foo 16 9.75s user 0.16s system 381% cpu 2.599 total
zhijie has quit [Read error: Connection reset by peer]
<mrvn> works repeadatly. Juhey.
zhijie has joined #ocaml
valross has quit [Quit: Ex-Chat]
zhijie has quit [Read error: Connection reset by peer]
<mrvn> Should I make the Digest.context thread safe? Meaning what if someone creates a context and then uses it in 2 threads?
<mrvn> Without lock the result would be completly random. With lock it would be one of 2 results.
zhijie has joined #ocaml
<flux> if it doesn't crash, it's safe enough
<mrvn> As long as it isn't finalized it won't crash :)
<mrvn> Has anyone written custom_operations before? I've only written finalize() yet but I think I should write the others too for Digest.context.
<flux> I'm not sure, but shuoldn't be difficult. atleast you should provide compare. maybe hash.
<mrvn> serialize is needed for Marshal, right?
<mfp> yes
hyperboreean has quit [Remote host closed the connection]
zhijie has quit [Read error: Connection reset by peer]
zhijie has joined #ocaml
avsm1 has joined #ocaml
oc13 has quit [Quit: Leaving.]
avsm has quit [Ping timeout: 256 seconds]
<mrvn> What is a prime number smaller than 31bit int?
pimmhogeling has quit [Read error: Connection reset by peer]
<quelqun_dautre> a prime number that fit in a 31bit int.
<mrvn> yes. But I need such a number. The largest one
<mrvn> Largest prime smaller than max_int on 32bit cpus.
sepp2k has joined #ocaml
<thelema> apparently 2^31 - {1, 19, 61, 69, 85, 99, 105, 151, 159, 171} are all prime
pimmhogeling has joined #ocaml
{newbie} has joined #ocaml
Submarine_ has joined #ocaml
eldragon has quit [Ping timeout: 240 seconds]
pimmhogeling has quit [Read error: Connection reset by peer]
<mrvn> thelema: 2^31-1 would be negative.
<mrvn> mellum gave me: for ((i=$((2**30));i--;)) [ $(factor $i | wc -w) -le 2 ] && echo $i
<thelema> mrvn: ok, 2^30 - {35, 41, 83, 101, 105, 107, 135, 153, 161, 173}
<thelema> but that's a nice bit of shell scripting.
bzzbzz has joined #ocaml
ztfw` has joined #ocaml
ztfw has quit [Read error: Connection reset by peer]
pimmhogeling has joined #ocaml
mrvn has quit [Ping timeout: 252 seconds]
Submarine_ has quit [Quit: Leaving]
eldragon has joined #ocaml
zhijie has quit [Read error: Connection reset by peer]
zhijie has joined #ocaml
zhijie has quit [Read error: Connection reset by peer]
zhijie has joined #ocaml
mrvn has joined #ocaml
zhijie has quit [Read error: Connection reset by peer]
zhijie has joined #ocaml
derdon has joined #ocaml
albacker has joined #ocaml
_unK has joined #ocaml
{newbie} has quit [Quit: {newbie}]
tmaedaZ is now known as tmaeda
f[x] has quit [Ping timeout: 248 seconds]
f[x] has joined #ocaml
quelqun_dautre has quit [Ping timeout: 260 seconds]
wu` has joined #ocaml
Leonidas has quit [Ping timeout: 276 seconds]
quelqun_dautre has joined #ocaml
Leonidas has joined #ocaml
{newbie} has joined #ocaml
<sc30317> thelema, you there?
<sc30317> mrvn, you there?
yakischloba has joined #ocaml
<sc30317> hey all, I want to create a function in ocaml. how can I make a call to another function?
<schme> sc30317: ?
<sc30317> schme, here is my question
<sc30317> I have a function(trainData, lr, max, init) that I want to create
<sc30317> I want to call another function I created earlier
<sc30317> on trainData
<sc30317> within the new function
<sc30317> how/can I do that?
<flux> sc30317, this sounds a very very basic question, something a tutorial would show in its first steps, no?
<schme> let x y = y + 1 ;; let z y = x y ;; ?
<sc30317> flux, I don't think so
<sc30317> schme, not like that
<schme> Ok, then I misunderstand.
<sc30317> maybe I should post my code, would that help to see the problem?
<flux> perhaps
<schme> (:
<sc30317> obviously it is giving me a Syntax error on line 54
<schme> is line 44 what we should be looking at?
<albacker> no need for ( and ) around the arguments.
<sc30317> albacker, you mean in the sde3 part?
<flux> sc30317, so what's the problem? the syntax?
<albacker> is sde3 meant to be the name of a function?
<sc30317> albacker, yes
<albacker> and the rest are arguments right?
<sc30317> albacker, I believe so
<albacker> well yeah no need for parantheses then.
<albacker> did you write the code btw? : sc30317
<sc30317> flux, I think so - I can't call create_winit within sde3
<sc30317> albacker, yes
<flux> sc30317, let-statements can only contain expressions. there is no expression let a = b, the expression form is let a = b in expr
<flux> sc30317, so what do you want to do with the x?
<flux> sc30317, in any case, your code will compile if you add "in ()" to the end of line 45
<sc30317> I would like x to contain the output of a call to create_winit trainData
<schme> I'm 100% sure this is in some tutorial somewhere (:
<schme> I'm gonna look it up right now.
<sc30317> schme, thanks
<sc30317> I have looked for a while
<sc30317> flux, adding the in () does make it compile
<sc30317> but why?
<flux> sc30317, www.ocamltutorial.org
<flux> sc30317, let a = let b = 4 is a non-sensical ocaml statement
<flux> sc30317, because let b = 4 is not an expression
<schme> flux: yes. I found it in there too.
<sc30317> schme, where?
<albacker> let func arg = let x = anotherfunc arg in dosomething_with x < sc30317 it should look smth like this i think.
<schme> sc30317: I clicked if statements, loops and recursion and it has example of using in
orbitz has quit [Quit: Reconnecting]
orbitz has joined #ocaml
<schme> reason I clicked that one is because my pointer was there.
<sc30317> ok
<sc30317> flux, if I add that in ()
<sc30317> and then after I run sde3
<sc30317> and I run x;;
<sc30317> it says x is unbound?
<schme> sc30317: how about this: let x y = let z = 7 in y + z ;;
<sc30317> wouldn't I have bounded it when I did the sde3?
<sc30317> schme, can I not do the let var = function in () more then 1 time?
<schme> sorry you've lost me.
<sc30317> ok, hold on -> ill write some code and I will try and show you what I am aiming to do
<mrvn> sc30317: let x = ... in expr only binds x for the duration of expr. After that it is unbound again.
<sc30317> mrvn, so that means when I do the next let it will unbound it?
<sc30317> if that is so, how could I bind it longer?
<mrvn> no, expr can be a let y = .. in expr2
<mrvn> You can chain as many lets as you like but once sde3 is finished all the lets in there are gone. They are only available inside sde3.
<mrvn> They are like local variables in C.
<sc30317> mrvn, ok
<sc30317> so what does expr2 signify?
<mrvn> any expression
<sc30317> so I could do
<sc30317> let input_vector = create_input_vector trainData in sde3?
<sc30317> is that what you are trying to say?
<mrvn> you can
<mrvn> Doesn't make much sense but you can
<albacker> sc30317 has the ability to make ocaml look senseless :P
<sc30317> albacker, thanks haha
<mrvn> That is like in C fn *input_vector = create_input_vector(trainData), sde3;
<sc30317> oh ok
<sc30317> so yea I don't want to do that
f[x] has quit [Ping timeout: 260 seconds]
<sc30317> how would I do like x = create_input_vector(trainData)
<sc30317> in ocaml?
<mrvn> If you bind input_vector to something then you better use it for something. Otherwise that is mostly useless
<mrvn> let x = create_input_vector trainData in something-that-uses x
<schme> let sde3 arg = let x = make-shit arg in fronk arg ;;
<schme> uh yeah.
<mrvn> let sde3 arg = let x = make-shit arg in fronk x;; you mean
<schme> mrvn: right :)
<schme> mrvn - the online ocaml compiler :P
<sc30317> mrvn, does it matter what you use x for?
<mrvn> no. It just makes no sense to bind it and not use it.
<sc30317> ok
<sc30317> so to bind them, I could just do some error checking on them?
<sc30317> like this?
<sc30317> let input_vector = create_input_vector trainData in
<sc30317> if input_vector = [0.0] then failwith "no"
<schme> try it out (:
<sc30317> schme, I am! :D
<sc30317> that gives me an error for the second variable I try to bind?
<schme> sc30317: Why does it do that?
<sc30317> i'm thinking it has something to do with calling it within sde3
<sc30317> do I need to add ;;
f[x] has joined #ocaml
<sc30317> to the end of each let within sde3?
<mrvn> schme: if you want to use let again after the if then you need to use 'expr1 ; expr2', i.e. add a ; between them
* schme pets tab-completion.
<mrvn> ;; ends the input. You only need one of them in the interactive toplevel
<mrvn> schme: grrrr. change your nick :)
schme is now known as schmx
<schmx> :P
<sc30317> well both of those ways give me an error
<schmx> I go to sleep
Drk-Sd has joined #ocaml
<sc30317> mrvn, is this what you were trying to tell me to do?
pimmhogeling has quit [Ping timeout: 265 seconds]
<sc30317> let sde3(trainData, lr, maxiterations, winit)=
<sc30317> let input_vector = create_input_vector trainData in
<sc30317> if input_vector = [0.0] then failwith "no"
<sc30317> ;
<sc30317> let winit = create_winit trainData in
<sc30317> if winit = [0.0] then failwith "no"
<sc30317> ;
<sc30317> let vector_class = create_vector_class trainData in ()
<sc30317> if vector_class = [0.0] then failwith "no"
<sc30317> ;
<mrvn> in () if ... makes no sense. "()" isn't a function
avsm has joined #ocaml
<sc30317> oh shoot
<sc30317> sorry
<sc30317> forgot to delete that one
<sc30317> now I am able to get through all of those letst
<mrvn> And it looks much better if you do the lets first and then the ifs.
<sc30317> I am doing the lets first then the ifs
avsm1 has quit [Ping timeout: 246 seconds]
<sc30317> would I need to put a ;; at the end to signify the end of the sde3 function?
<mrvn> no.
<albacker> is it me or those paranthees around the arguments should be removed?
<mrvn> albacker: he writes C
<sc30317> albacker, I think I need them, because you need to pass the commas with the variables
<sc30317> like you would have to pass sde3(inData, 0.25, 10, []);;
<mrvn> sc30317: normaly one doesn't.
<sc30317> will ocaml deal with the commas then?
<sc30317> or could I just put
<mrvn> You declared sde3 as a function taking one argument, a 4-tuple. Normaly one would declare sde3 as function taking 4 arguments.
<sc30317> let sde3 trainData, lr, maxiterations, winit=
<albacker> sc30317, http://pastebin.org/116983
<mrvn> let sde3 trainData lr maxiterations winit =
<sc30317> mrvn, got it
Smerdyakov has joined #ocaml
jcaose has quit [Quit: Leaving]
<sc30317> can I increment an int? (similar to i++ in c?)
<mrvn> nope. only a ref
<sc30317> so if i have i = 0 in
<sc30317> I would have to do i = 1 in to increment it?
<Smerdyakov> sc30317, when you have another question like that, first ask yourself whether you can do it in math. If not, you probably can't in OCaml, either.
<sc30317> Smerdyakov, sounds good
<mrvn> sc30317: that doesn't increment it. That just creates a new one
<sc30317> ok
<mrvn> # let i = 1 in (let i = 2 in i) + i;;
<mrvn> - : int = 3
{newbie} has quit [Quit: {newbie}]
<sc30317> thanks mrvn
* Smerdyakov thinks: This is the kind of question that people don't have when they learn programming languages along with program logics.
<sc30317> Smerdyakov, i'm sorry; im trying really hard with this
<mrvn> It shows a fundamental lack of understanding what functional programming is
<Smerdyakov> sc30317, I'm not trying to cast aspersions on you. Instead, I'm commenting on the widespread use of poor pedagogy.
* mrvn too
<sc30317> Smerdyakov, thats definitely true :D
<mrvn> sc30317: Did your course start off with implementing a factorial function? List manipulations?
<sc30317> nope, nothing
<sc30317> just got thrown into this
<sc30317> is there a way to convert a list to a string?
<mrvn> Doing 3D vector/matrix multiplications is really no way to learn ocaml.
<mrvn> sc30317: yes
<sc30317> mrvn, I agree with you
<mrvn> Wherer there is a will there is a way
<sc30317> mrvn, true
<sc30317> I guess I should have worded my question differently
<sc30317> is there a standard function to convert a List to a string
<Smerdyakov> sc30317, your question is too vague.
<Smerdyakov> sc30317, so far, an answer is: "Yes, the function that always returns the empty string."
<sc30317> Smerdyakov, let me word it better
<sc30317> I have a List of lists
<Smerdyakov> [There's no reason to capitalize "list" there.]
<sc30317> I would like to turn that into a string so that I can print it out using print_string
<Smerdyakov> You should try to avoid IO in OCaml, especially as a beginner.
<Smerdyakov> Instead, just evaluate the expression whose value you're curious about.
<sc30317> Smerdyakov, I know- but that is what this program has to do
<mrvn> let implode list = let s = String.create (List.length list)# let implode list = let s = String.create (List.length list) in let rec loop i = function [] -> s | c::cs -> s.[i] <- c; loop (i + 1) cs in loop 0 list;;
<mrvn> val implode : char list -> string = <fun>
<mrvn> # implode ['H';'a';'l';'l';'o'];;
<mrvn> - : string = "Hallo"
<sc30317> mrvn, thanks
<sc30317> I am working on some code
<sc30317> I will post in a second to ask questions about
{newbie} has joined #ocaml
<mrvn> # let string_of_vec v = List.fold_left (fun s x -> Printf.sprintf "%s %f" s x) "" v;;
<mrvn> val string_of_vec : float list -> string = <fun>
<mrvn> # string_of_vec [1.0; 2.0; 3.0];;
<mrvn> Now you do string_of_matrix
<mrvn> - : string = " 1.000000 2.000000 3.000000"
<sc30317> but I would like to leave the brackets and semicolons in
<Smerdyakov> mrvn, how do you know that you aren't writing a significant portion of his homework solution for him right now?
avsm has quit [Quit: Leaving.]
<sc30317> and it is going to be a List of Lists or a List
avsm has joined #ocaml
<Smerdyakov> Please stop capitalizing "list."
<sc30317> sorry Smerdyakov
avsm has quit [Client Quit]
<albacker> do you guys also solve Java homework?
<Smerdyakov> sc30317, your first source of help should be course staff. Have you asked them these questions yet?
<sc30317> yes
<sc30317> he says RTFM
<sc30317> literally
<Smerdyakov> You might want to complain to some higher power within the university.
<sc30317> I would; however, my professor is the higher power
<Smerdyakov> He's the university president? :)
<sc30317> no
<sc30317> he is the head of the department
<Smerdyakov> You might want to switch universities. :P
<sc30317> last semester
<Smerdyakov> What is the subject matter of this class?
<sc30317> programming languages
<sc30317> he is teaching us 4 different ones this semestter
f[x] has quit [Ping timeout: 240 seconds]
mrvn has quit [Ping timeout: 258 seconds]
<albacker> thats really general in my opionion
<sc30317> albacker, I agree
mrvn has joined #ocaml
<Smerdyakov> It seems to be a universal truth that 90% of students can't learn OCaml in less than a full dedicated semester.
<albacker> i'm in 2nd year of university and i've had several subjects for several languages. even 2 subjects for one language
<albacker> Smerdyakov, http://norvig.com/21-days.html
<Smerdyakov> albacker, what are you trying to convey by giving that link?
<albacker> one semester is not enough for anything :D
{newbie} has quit [Quit: {newbie}]
<Smerdyakov> That's obviously false, so I'll ignore it unless you make a more specific statement. :P
<albacker> nice article btw, i invite you to read it.
* Smerdyakov spends 999 hours trying to find the code that does the default scaffolding in Ruby on Rails, just so he can count the number of lines in it. :(
f[x] has joined #ocaml
smimou has quit [Ping timeout: 260 seconds]
smimou has joined #ocaml
f[x] has quit [Ping timeout: 240 seconds]
joewilliams_away is now known as joewilliams
philtor has joined #ocaml
tmaeda has quit [Ping timeout: 246 seconds]
<ttamttam> Hello
<ttamttam> I have a small question about camlp4
<ttamttam> I'd like to see the code (pretty printer part) generated when applying a syntax extension on a source file
<ttamttam> But can't figure out how to do.
<ttamttam> I tried some variations around : camlp4o -I .. bitstring.cma bitstring_persistent.cma pa_bitstring.cmo toto.ml
<ttamttam> But this produces (?) byte code ?
tmaedaZ has joined #ocaml
f[x] has joined #ocaml
<mfp> ttamttam: add pr_o.cmo to the list of modules, otherwise camlp4o will generate a binary serialization of the AST when you redirect the output
<ttamttam> mfp: Thanks ;-)
<Smerdyakov> How ugly is _that_....
philtor has quit [Ping timeout: 256 seconds]
ttamttam has quit [Quit: Leaving.]
oc13 has joined #ocaml
<sc30317> can I do a for loop like this?
<sc30317> for( i = 0 to head_length(x) do
<sc30317> print_float List.nth(x) i
<sc30317> done
<Smerdyakov> Please don't use loops in OCaml. I wish they weren't in the language.
<thelema> sc30317: Smerdyakov is our resident purist
<Smerdyakov> His particular example is just dying for one of the most standard higher-order functions.
<sc30317> Smerdyakov, ok
<thelema> Smerdyakov: yes, he's not yet learned about map and iter
<sc30317> if I don't use a loop, then how would you print the floats in a list?
f[x] has quit [Ping timeout: 268 seconds]
<Smerdyakov> An awful loop may be the best choice given your crappy course situation.
<thelema> List.iter print_float x
<Smerdyakov> That will do what a reasonable fix-up of his code would do, but it won't do what he really wants. :D
<sc30317> Smerdyakov, you are right
<sc30317> if I do the List.iter print_float x
<sc30317> it prints them all out
<sc30317> but it doesn't add a space
<sc30317> in between each float
<sc30317> is there a way I can add a space?
<schmx> maybe make a function that prints the space \o/
<jonafan> or use the printf module
<sc30317> well I could make a module that prints a space or use the printf module, but that doesn't make a space between each iteration in the List.iter
<schmx> unless.. you use that for iteration.
<sc30317> schmx, how do you mean?
<jonafan> List.iter (Printf.printf "%f ") x
<sc30317> jonafan, oh ok
<jonafan> there are handy formatting options too
<sc30317> gotcha
<jonafan> another option: convert floats to strings and use String.concat
<sc30317> jonafan, this works great! thanks :D
<jonafan> String.concat " " (List.map string_of_float x)
<jonafan> print_endline (String.concat " " (List.map string_of_float x))
Drk-Sd has quit [Quit: foo]
f[x] has joined #ocaml
ulfdoz has joined #ocaml
<sc30317> is there a way to compare 2 lists to see if each element has the same sign?
oc13 has quit [Ping timeout: 264 seconds]
<jonafan> have a look at List.for_all2
<sc30317> thanks jonafan
f[x] has quit [Ping timeout: 260 seconds]
Smerdyakov has left #ocaml []
f[x] has joined #ocaml
oc13 has joined #ocaml
f[x] has quit [Ping timeout: 268 seconds]
oc13 has quit [Ping timeout: 240 seconds]
Submarine has joined #ocaml
enthymeme has joined #ocaml
ttamttam has joined #ocaml
oc13 has joined #ocaml
joewilliams is now known as joewilliams_away
_zack has quit [Quit: Leaving.]
_zack has joined #ocaml
<sc30317> jonafan, I have been trying to figure out how to get List.for_all2 working
<sc30317> I cant seem to understand how it works
fraggle_ has quit [Remote host closed the connection]
<jonafan> what are you doing again?
<jonafan> you're trying to compare pairs and make sure they have the same sign?
<sc30317> trying to compare 2 lists
<sc30317> correct
<thelema> Here's an example:
<jonafan> so you write a function that compares two floats and returns true if they have the same sign
<thelema> List.for_all2 (fun x y -> x > y) [6;3;1;7] [4;2;0;4]
<thelema> this doesn't do what you want, but might help you understand how to use it.
<jonafan> that example verifies that the items in the first list are larger than the corresponding item in the second
Yoric has quit [Quit: Yoric]
<sc30317> yes, I see that
<sc30317> I tried it
<sc30317> so I would use like
<sc30317> List.for_all2( fun x y -> (x > 0 & y > 0) | (x < 0 & y < 0) list1 list2
<sc30317> ?
<thelema> excepting parentheses problems, yes
fraggle_ has joined #ocaml
<sc30317> which parenthesis problems?
<sc30317> just that i don't need to have them?
<thelema> you're missing a close ), and your spacing around the first open ( is wierd
<sc30317> ok ill fix it
<thelema> an alternative test would be x *. y > 0.
<sc30317> oh yea
<sc30317> I guess I could do it that way as well
<sc30317> for booleans, would I do this to check?
<thelema> don't forget the difference between 0. and 0
<sc30317> if var = 'true' then print_string "yes"
<thelema> 'true'? no, just true
<sc30317> ok
<thelema> and testing if something is true is kinda useless
<sc30317> sorry thelema, my C is still coming into play :D
<thelema> booleans can only be true or false in ocaml.
smimou has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
<sc30317> what is wrong with this?
<sc30317> let correct = List.for_all2 (fun x y -> x > 0 & y > 0 | x < 0 & y < 0 list1 list2) in
<thelema> the close ) should be after the last 0
<thelema> List.for_all2 takes three arguments: a function and 2 lists
<sc30317> nope, even when I do that, it gives me a syntax error
<thelema> the way you have it written, it's only receiving one argument: a function (with bad syntax)
<thelema> try replacing the & with && and | with ||
<sc30317> yup
smimou has joined #ocaml
_zack has quit [Quit: Leaving.]
smimou has quit [Ping timeout: 268 seconds]
_zack has joined #ocaml
smimou has joined #ocaml
boscop has joined #ocaml
bjorkintosh has quit [Ping timeout: 264 seconds]
smimou has quit [Read error: Operation timed out]
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
smimou has joined #ocaml
krankkatze has joined #ocaml
itewsh has joined #ocaml
bjorkintosh has joined #ocaml
_andre has joined #ocaml
<_andre> hello
<_andre> does anyone know if ocsigen can work with multiple-processes?
<_andre> kinda like apache pre-fork for example
<_andre> or do i have to run multiple servers and use some kind of proxy in front of them?
bjorkintosh has quit [Ping timeout: 260 seconds]
<thelema> _andre: try #ocsigen
<_andre> should have figure that channel existed :p
<_andre> thanks
<_andre> figured*
<_andre> it's not exactly crouded though...
<thelema> http://www.mail-archive.com/caml-list@yquem.inria.fr/msg05360.html <- Just fire up n instances and dispatch with a proxy
<_andre> thanks!
enthymeme has joined #ocaml
<mfp> _andre: why do you want multiple processes anyway?
<thelema> clearly so he can satisfy the million hits per day his site is getting.
<mfp> (Ocsigen's Eliom is not a blocking framework à la Rails)
Yoric has joined #ocaml
<_andre> well, i figured if i have multiple cores i could use them
<thelema> he needs to take advantage of his 32-core web-servers.
<_andre> funny.
<thelema> 8-CPU quad core boxes. They're the wave of the future.
<_andre> mfp: i'm just getting started with ocsigen, it was just something i was wondering about
<_andre> pre-fork + lwt for each core seems to make sense for me
_zack has quit [Read error: Connection reset by peer]
_zack has joined #ocaml
<sc30317> I have a number
<sc30317> and I have to make a vector that is x of those numbers
<sc30317> how do I create this vector?
<sc30317> ex.
<sc30317> if I input .25 and I have a length of 3
<sc30317> then the output vector needs to be [.25;.25;.25]
<thelema> well, batteries' List.init would work great. Otherwise you'll have to write your own recursive function. pretty trivial
<sc30317> ok
demitar has joined #ocaml
<sc30317> how would I write my own recursive function?
<sc30317> let rec vector_create lr = function [], | ::lr
<sc30317> would something like that work?
<thelema> let dup n x = x :: dup (n-1) x
<thelema> but better.
<sc30317> but better?
<thelema> yes, with a base case for the recursion
smimou has quit [Ping timeout: 268 seconds]
<sc30317> oh ok
<sc30317> h/o let me see if I can come up with something
smimou has joined #ocaml
<sc30317> thelema, if I do what you said, I get a syntax error
<sc30317> let rec dup n x = x :: dup (n-1) x
<thelema> rec?
<sc30317> yea I fixed that
<sc30317> I was trying to figure out something else wrong with hit
<sc30317> *with it
<thelema> no syntax error on my box
<thelema> value dup : int -> 'a -> list 'a = <fun>
<sc30317> val dup : int -> 'a -> 'a list = <fun>
<thelema> oh yeah, revised types.
<thelema> ignore the difference
<sc30317> oh ok
<sc30317> but then if I put in dup 0.25 10;;
<thelema> if you run it, it'll overflow the stack.
<sc30317> Error: syntax error
<sc30317> yea I got that error too
smimou has quit [Ping timeout: 268 seconds]
<sc30317> why?
<thelema> odd that it gives you a syntax error
<sc30317> no I was just being an idiot
<sc30317> now its a stack overflow
<sc30317> why would that be?
<sc30317> no base case?
<jonafan> stack overflow is caused by too many recursive function calls
<sc30317> jonafan, thats what I figured
<jonafan> in this case, recursion can never terminate
<thelema> yes, no base case
<sc30317> what would I need to do to add the base case?
<thelema> check if n=0
<jonafan> in what situation would you want to return an empty list?
<sc30317> jonafan, if there is no number entered?
<jonafan> okay so build on that
<sc30317> let rec dup n x = x :: dup (n-1) x
<sc30317> if n = 0 failwith "no base case"
<jonafan> haha
<sc30317> well you told me to build on it?
<sc30317> haha
<jonafan> your function, the first thing it should do is check for n being less than or equal to 0
<jonafan> if it is zero, it returns an empty list
<jonafan> otherwise, it returns x :: (your function with n - 1)
<jonafan> let rec dup n x = if x <= 0 then [] else x :: dup (n - 1) x
<sc30317> haha thats what I was just about to say joewilliams_away
<sc30317> thats what I was just about to say jonafan
<jonafan> there are more tricks available to make it more efficient, but it's probably not worth the effort
<jonafan> you could make a tail recursive version using an accumulator
<jonafan> let dup n x = let rec f n accum = if n <= 0 then accum else f (n - 1) (x :: accum) in f n []
<jonafan> also don't write your functions on one line like that
<sc30317> I don't
<derdon> rwmjones: ping
<sc30317> I can't see them that way
_zack has quit [Quit: Leaving.]
oc13 has quit [Ping timeout: 248 seconds]
smimou has joined #ocaml
oc13 has joined #ocaml
tmaedaZ has quit [Ping timeout: 276 seconds]
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
ikaros has joined #ocaml
tmaedaZ has joined #ocaml
f[x] has joined #ocaml
smimou has quit [Ping timeout: 268 seconds]
ttamttam has quit [Quit: Leaving.]
smimou has joined #ocaml
rwmjones has quit [Ping timeout: 256 seconds]
smimou has quit [Read error: Operation timed out]
rwmjones has joined #ocaml
<derdon> rwmjones: helo
<derdon> rwmjones: I think I found a typo in a wiki article
smimou has joined #ocaml
<thelema> derdon: email him for a logon, or I can fix it now.
<derdon> thelema: the problem is, that I don't understand the sentence. technically, I could fix it as well. it is in http://www.ocaml-tutorial.org/compiling_with_gnu_make: "Note that libraries that not part of the standard library but are shipped with any standard OCaml installation such as unix, str or bigarray are automatically considered as Findlib packages."
jcaose has joined #ocaml
<thelema> better?
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
<derdon> yep
Associat0r has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Associat0r has quit [Client Quit]
smimou has quit [Read error: Operation timed out]
enthymeme has joined #ocaml
<thelema> eek! I'm blinded looking at the code menhir produces
<thelema> I'm about to find out what happens when you have an ocamllex rule that matches the empty string
ulfdoz has quit [Ping timeout: 246 seconds]
mrvn has quit [Ping timeout: 240 seconds]
mrvn has joined #ocaml
smimou has joined #ocaml
smimou has quit [Changing host]
smimou has joined #ocaml
jeddhaberstro has joined #ocaml
matthieu has joined #ocaml
matthieu has quit [Remote host closed the connection]
maattd has joined #ocaml
Submarine has quit [Quit: Leaving]
sepp2k has quit [Quit: Leaving.]
oc131 has joined #ocaml
maattd has quit [Remote host closed the connection]
oc13 has quit [Ping timeout: 276 seconds]
rwmjones has left #ocaml []
rwmjones has joined #ocaml
Drk-Sd has joined #ocaml
<rwmjones> derdon, didn't I send you an invite before? I thought I did ..
<derdon> rwmjones: yes, you did. Like I already said, "technically, I could fix it"
<derdon> rwmjones: but I didn't understand what you wanted to express with the original sentence
<rwmjones> ah ok ... looks like thelema fixed it anhow
<rwmjones> anyhow
<derdon> yes
<thelema> I gave my best try.
jcaose has quit [Quit: Leaving]
<thelema> I like getting emails on updates to the wiki, so I can see tiny things that can be written better.
<thelema> I can't take up all my time editing the wiki, so it's good that there's not too many changes
<derdon> I removed an HTML tag inside a code block cus it was visible there as is
<derdon> so I used ReST notation: ``foo``
<derdon> thelema and rwmjones: are you currently working on any ocaml project?
krankkat` has joined #ocaml
<thelema> derdon: ocaml batteries
<thelema> ``foo`` works?
eldragon has quit [Ping timeout: 246 seconds]
<derdon> thelema: what do you mean with ``works``? see the 2nd code block there: http://www.ocaml-tutorial.org/compiling_with_omake
<_andre> is there a way to convert a string like "%s - %d" into a format type accepted by printf?
eldragon has joined #ocaml
<derdon> thelema: ``ocamldep``
eldragon has quit [Read error: Connection reset by peer]
eldragon has joined #ocaml
krankkatze has quit [Remote host closed the connection]
<derdon> thelema: or do you think pure double / single quotes are better?
jonafan_ has joined #ocaml
<thelema> ah, it doesn't do code highlighting. I was looking for a lighter alternative to <code></code>
<thelema> [] might be good,
<thelema> instead of ``ocamldep``
<thelema> _andre: it's automatically converted by the compiler if it's a literal string.
<thelema> _andre: if it's not, better to just use %a, I think.
fraggle_ has quit [*.net *.split]
sshc has quit [*.net *.split]
emias has quit [*.net *.split]
jlouis has quit [*.net *.split]
sshc has joined #ocaml
albacker has quit [Ping timeout: 260 seconds]
enthymeme has quit [Quit: off to clas]
oc131 has quit [Ping timeout: 240 seconds]
derdon has quit [Quit: derdon]
<_andre> thelema: thanks, i'll check %a
jonafan has quit [Ping timeout: 260 seconds]
fraggle_ has joined #ocaml
emias has joined #ocaml
jlouis has joined #ocaml
<sc30317> thelema, I am having trouble with this function
<sc30317> why would this not work?
<sc30317> I can post the whole code if that would be helpful
<olegfink> sc30317: I think you meant failwith instead of fail with
<sc30317> olegfink, yes, thanks
<olegfink> (was that the problem?)
<sc30317> now I know what the problem is
<sc30317> this line
<sc30317> else let winit = lr_vector + multiply_test(input_vector lr_vector) in
<sc30317> I want to add lr_vector (which is a vector)
<sc30317> to multiply_test(input_vector lr_vector)
<sc30317> which is a vector
<sc30317> so I need to add the 2 vectors togetther
<sc30317> is there an easy way to add a 2 lists together?
<sc30317> like if you have
<sc30317> [a;b;c] + [d;e;f]
<olegfink> List.map2 (+) list1 list2
<sc30317> olegfink, thanks, ill try that
fraggle_ has quit [*.net *.split]
emias has quit [*.net *.split]
jlouis has quit [*.net *.split]
<sc30317> olegfink, so all I have to do to add 2 Lists together is List.map2 (+) list1 list2
<sc30317> ?
<sc30317> because when i do that, it says that the function is applied to too many arguments;
<olegfink> yes, as stated in the manual, List.map2 f [a1;...;an] [b1;...;bn] is [f a1 b1;...;f an bn]
<sc30317> (*Add 2 vectors together *)
<sc30317> let vector_add input1 input2 = List.map (+.) input1 input2
<sc30317> gives me an error
<sc30317> I tried it with just a + instead of a +. and got the same error
<olegfink> map2, not map
<sc30317> shoot
<sc30317> what a dummy I am
fraggle_ has joined #ocaml
emias has joined #ocaml
jlouis has joined #ocaml
flx_ has joined #ocaml
flx_ is now known as Guest43138
<olegfink> if you have a lot of list arith, you might want to name vector_add as an operator:
<sc30317> nope, not much to do
krankkat` has quit [Remote host closed the connection]
<sc30317> olegfink, I have 1 more question
<sc30317> why is this a syntax error? I am going to pastebin you the whole function
ned has joined #ocaml
<olegfink> # let (+:) = List.map2 (+) ;;
<olegfink> # [1;2;3] +: [4;5;6] ;;
<olegfink> - : int list = [5; 7; 9]
Dawrk-Side has joined #ocaml
ned is now known as Guest20867
Yoric has quit [Quit: Yoric]
Drk-Sd has quit [*.net *.split]
smimou has quit [*.net *.split]
_andre has quit [*.net *.split]
quelqun_dautre has quit [*.net *.split]
zhijie has quit [*.net *.split]
Guest80479 has quit [*.net *.split]
thieusoai has quit [*.net *.split]
brendan has quit [*.net *.split]
flux has quit [*.net *.split]
smimram has joined #ocaml
Guest43138 is now known as flux
zhijie has joined #ocaml
<olegfink> you probably want parens around mutiply_test(...)
<sc30317> I have parens around them
<sc30317> at least I do in the pastebin?
_andre has joined #ocaml
<olegfink> around the whole application
<olegfink> also you're missing 'in' after let winit = ...
<sc30317> ok, added -> didn't fix it
<sc30317> yea I added that as well and it didn't help
fraggle_ has quit [*.net *.split]
emias has quit [*.net *.split]
jlouis has quit [*.net *.split]
<olegfink> the code doesn't really makes sense; what is the 'winit' binding at the end of 'for' body for?
<sc30317> I was just using a test case for the let....in
<sc30317> I was just saying if winit is an empty list then failwith the message
<olegfink> ok... which line is syntax error for you?
quelqun_dautre has joined #ocaml
thieusoai has joined #ocaml
brendan has joined #ocaml
fraggle_ has joined #ocaml
emias has joined #ocaml
jlouis has joined #ocaml