flux changed the topic of #ocaml to: 3.11.0+rc1 is out! | Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.0beta1 available from http://caml.inria.fr/pub/distrib/ocaml-3.11/ | Or grab OCaml 3.10.2 from http://caml.inria.fr/ocaml/release.html
Kerris7 has quit []
alexyk has joined #ocaml
vixey has quit [Read error: 110 (Connection timed out)]
jlouis has quit [Remote closed the connection]
asabil has quit [Read error: 110 (Connection timed out)]
asabil has joined #ocaml
alexyk has quit []
alexyk has joined #ocaml
willb has joined #ocaml
asabil has quit [Read error: 110 (Connection timed out)]
asabil has joined #ocaml
fschwidom has joined #ocaml
Stefan_vK1 has joined #ocaml
sporkmonger has joined #ocaml
Stefan_vK has quit [Read error: 110 (Connection timed out)]
fschwidom has quit [Remote closed the connection]
AlexyK_ has joined #ocaml
<AlexyK_> Well iPhone has a colloquy too, so can chat about OCaml anywhere
<AlexyK_> Got Real World Hadkell today, one could rewrite half of it into OCaml
AlexyK_ has quit ["Rooms • iPhone IRC Client • http://rooms.derflash.de"]
AlexyK_ has joined #ocaml
AlexyK_ has quit [Client Quit]
Mr_Awesome has quit [Read error: 60 (Operation timed out)]
threeve has joined #ocaml
thelema has quit [Read error: 104 (Connection reset by peer)]
Amorphous has quit [Read error: 110 (Connection timed out)]
pumpkin has quit []
pumpkin_ has joined #ocaml
alexyk has quit []
jeddhaberstro has quit []
alexyk has joined #ocaml
christo_m has joined #ocaml
<christo_m> http://rafb.net/p/f2FJyv82.html <- why is the last else being underlined there
<christo_m> i noted that the for loop should be osmethign like for i = 0 to n
<christo_m> man
<christo_m> is there anyone in here who can help please?
<christo_m> flux, you there?
alexyk has quit []
<mbac> hmmm
<christo_m> mbac hold on
<christo_m> i made updates
<christo_m> still get errors
<mbac> you're returning unit in if n > 0 but a in else if n = 0
<mbac> (unit's another word for nothing)
<christo_m> mbac, but f isa function in the arguments
<christo_m> and a is its argument
<christo_m> f will return an int
<christo_m> f of a will also
<mbac> your for loop is basically doing this for i = 0 to n do ignore (f a) done
<christo_m> ignore?
<mbac> discarding the return values
<christo_m> why does it discard the values
<christo_m> how do imake it not do this
<mbac> it's not clear what you want it to do
<christo_m> well i just told you
<christo_m> i want to call teh function n times with parameter a
<christo_m> im basically doing it recursively but with a for loop
<mbac> that's exactly what it's doing
<christo_m> as per the assignment
<christo_m> ah should i do iterator_for f a
<christo_m> instead?
<mbac> for loops don't evaluate to a result when they exit, they're imperative constructs
<christo_m> k i dont know how to do this
<christo_m> those are the requirements
<christo_m> im not asking u to do the assignment for me, im just showing you how stupid this is
<christo_m> mbac?
<mbac> i think you will need to use ref cells
<christo_m> like, let x = ref 0?
<mbac> exactly
<christo_m> hmm
<christo_m> not sure how i would use them
<christo_m> you mean storing the value of f a
<christo_m> into a reference
<christo_m> and constantly updating it upon each iteration?
<mbac> something like a for-loop body of x := f !x and then a final !x after the loop
<christo_m> ah
<christo_m> i still get an error btw, but im close
<christo_m> perhaps for the else statement after
<christo_m> i cant jus tdo "then a" i have to do "then a!"
<mbac> if n > 0 then begin ... end else if
<mbac> and a semi-colon after done
<christo_m> can i leave it as a or do i have to use the ! selector?
<christo_m> i get an error with the end :(
<mbac> statements need to be seperated with ;
<christo_m> OH yea
<christo_m> forgot
<mbac> also you will want an intermediate variable let x = ref a
<mbac> you can't turn a into a ref, it's already forced to be an int
<mbac> ok bed time, good luck ;)
<christo_m> WAIT
<christo_m> one mre thing
<christo_m> thanks
<christo_m> i appreciate it :D
thelema has joined #ocaml
Mr_Awesome has joined #ocaml
<christo_m> thelema, :D
<thelema> hi christo_m
apples` has quit ["Leaving"]
christo_m has quit ["figured out the fucking assignment, yesss"]
alexyk has joined #ocaml
threeve has quit []
<alexyk> Random.int in a binary always gives me the same sequence -- *must* I seed it from some voodoo time reading?
<thelema> you can use whatever entropy source you like.
<alexyk> thelema: congrats on being acknowledged in Real World Haskell in teh first group of > 1% commenters! :)
<thelema> huh? link?
<alexyk> I got the book today from Amazon! was one of the first pre-orderers :)
<alexyk> they list almost all of teh folks who commented, divided into >1%, >0.2%, and rest
<thelema> there are multiple thelemas out there - possible a different one?
<alexyk> and you're in the top group :)
<alexyk> well they use the same name as on the Batteries page :)
<alexyk> it's by name; unless I'm all mistaken
* thelema isn't involved in any haskell community.
* alexyk prolly totally mixed it up :)
* alexyk was going to ask how is it possible to ocntribute to bith Haskell and OCaml that much...
<alexyk> (contribute to both)
<thelema> not that I know of, at least.
<thelema> I guess there's another "Edgar Friendly" wandering around.
<alexyk> thelema: you compare batteries effort to haskell, right? :)
<thelema> to the haskell language? To be honest, I think of it more like implementing Java or the .net stdlib
<alexyk> thelema: ok ok... n any case it's an awesome book, we don't have such in ocaml; and half of it can be literally rewritten in ocaml
<thelema> is there wiki space for such an effort?
<thelema> (Sounds like a good community project)
<alexyk> thelema: interesting idea, I think it may be PLEAC for Haskell=> OCaml
<alexyk> <=>
<alexyk> well you can't get lazy evaluation easily I guess
<thelema> pleac?
<sbok> "Programming Language Examples Alike Cookbook"
jjong has quit [Read error: 104 (Connection reset by peer)]
<thelema> wow, ocaml's more complete than python
<alexyk> the ocaml guy is my hero; we all should thank him
<alexyk> I grep this file instead of reading docs :)
Amorphous has joined #ocaml
<thelema> (* There is no feature in OCaml resembling Perl's "taint mode". *) <- this might not be that hard to implement...
<thelema> it'd be all type system work anyway.
mandel has joined #ocaml
mandel has quit [Client Quit]
Yoric[DT] has joined #ocaml
Axioplase has quit ["bbl"]
Axioplase has joined #ocaml
Axioplase has quit [Client Quit]
Yoric[DT] has quit ["Ex-Chat"]
<flux> well, you'd need a separate IO library with phantom-typed return values
<flux> it would change a lot I'd say..
<flux> in any case I don't think taint-mode would be as useful in ocaml as it might be in perl..
pumpkin_ is now known as pumpkin
pumpkin has quit ["Leaving..."]
<alexyk> there's no List.take and List.drop??
<alexyk> omg... it's a first example in Real World Haskell...
<flux> I would imagine most of their uses would be replaced by String.sub in OCaml
<flux> although I would expect takeWhile and dropWhile would be more useful, I have not found use for them either
<flux> perhaps on a very rare occasion..
pumpkin_ has joined #ocaml
<alexyk> is there a process by which say we can add List.take and List.drop to List, or are they carved in stone?
<flux> well, there is the Batteries Included project, which indeed does have those functions
<flux> batteries aspires to be the standard community edition of the ocaml standard library
<alexyk> flux: so we'd have to do a sudden switch to it I guess? It really bothers me that libraries like List are limited and nobody cares, saying "well just write it"; and we'd have to wait for adoption of Batteries...
<flux> there is extlib, which the list-part of batteries is based on
<alexyk> flux: but who decided that List is untouchable?
<flux> alexyk, no one. you can just release your own List, the license allows it. tada, you've touched it \o/
<flux> or you can enter a bug report to the ocaml bug tracking system
<flux> in general the ocaml team is focused on developing the compiler, not so much the library, except for those features that support the compiler (think Printexc)
<alexyk> flux: ok, that's what I thought
<flux> but adding "take" to List seems a very minor change. infact, so minor that why bother. and doing a larger revamp is a big task. hence the batteries.
<flux> adding a few functions would only serve to make the new source incompatible with old compilers
<flux> implementing take/drop/etc where you need them (which you rarely do, in my opinion) takes only a few lines
<flux> albeit there are other functions which everyone appears to write, such as calling a function so that its return value is always a value, even if it raises an exception
<flux> things that everyone implement are nice to be in a standard library.
Kerris7 has joined #ocaml
asabil has quit ["Ex-Chat"]
ulfdoz has joined #ocaml
mtrimpe has quit []
Kerris7 has quit []
mishok13 has joined #ocaml
asabil has joined #ocaml
Yoric has joined #ocaml
tomh has joined #ocaml
tomh has left #ocaml []
ygrek_ has joined #ocaml
glondu has quit [Read error: 104 (Connection reset by peer)]
glondu has joined #ocaml
Kerris7 has joined #ocaml
vixey has joined #ocaml
Kerris7 has quit []
Kerris7 has joined #ocaml
ygrek_ has quit [Remote closed the connection]
Associat0r has joined #ocaml
<alexyk> I have an ocaml driver calling many unix binaries, and it fails after a while with:
<alexyk> .Fatal error: exception Unix.Unix_error(15, "pipe", "")
<alexyk> -- however, I do close all pipes; what is this error?
<pumpkin_> alexyk: you're up late!
<pumpkin_> or early
pumpkin_ is now known as pumpkin
<alexyk> pumpkin: and you? :)
<pumpkin> alexyk: yeah, gonna go to sleep soon or I'll die tomorrow... just working on my project right now :P
<flux> alexyk, are you sure you're not writing to a pipe that's closed? possibly by the other end
<alexyk> I just started running my ocaml-driven research, which is exciting so hard to sleep
<flux> (well: not "possibly" but exactly by the other end)
<alexyk> flux: actually I forgot to close channels, yet got exception on a pipe
<flux> alexyk, yes, but if the other end has closed the pipe and you write to it, you get that exception
<flux> alexyk, but, there's a solution to it
<flux> Sys.signal Sys.sigpipe Sys.Signal_ignore
<alexyk> flux: interesting... but I'm quite sure I don't write into a closed pipe -- I was doing open_in without close_in, somehow it clogged things; could it have caused that pipe error all by itself, e.g. without any more pipes available
<alexyk> ?
dabd has joined #ocaml
<alexyk> pumpkin: do you present today?
<pumpkin> alexyk: nope, tomorrow thank goodness :P
<alexyk> pumpkin: then hack away :) :)
<pumpkin> yeah :P gonna get some sleep first though
<pumpkin> I want to be energetic tomorrow
<alexyk> pumpkin: well there's still time ... and I'm going to watch my cool simulation to run out of pipes or something, after an hour or so usually
<pumpkin> what are you simulating?
<alexyk> pumpkin: I have a series of ngram models watching a person walk through a sensor field
<alexyk> it's all in ocaml calling external commands, parsing and aggregating results
<alexyk> it really all works the first time it compiles, amazing...
<flux> alexyk, EPIPE comes only from writes, and only when the reading end of the descriptor is closed.
<flux> alexyk, it's a unix error, you can read more about it with man 2 write
<alexyk> flux: ok! will check further
<alexyk> so what would be the result of Sys.signal Sys.sigpipe Sys.signal_ignore then? writing disappearing?
<pumpkin> alexyk: anyway, good luck with that, I'm hitting the hay :P
<flux> alexyk, the write will return 0 on EOF
<flux> alexyk, so likely your exception will just change to End_of_file..
<alexyk> pumpkin: g'night!
<flux> hmm, actually
<flux> I need to check that
<flux> yeah, actually I think you or some library might have already done that somewhere
<alexyk> flux: is there a way to open_in ic su that it's closed no matter which way you leave a function?
<flux> because EPIPE is the return code, not the sigpipe signal
<alexyk> I forgot to close_in in some places, and when I have several exit points, especially with exception, I have to close_in manually everywhere; I wish I'd have Ruby's or Python's "with file
<alexyk> " block
<flux> alexyk, unfortunately no. but you can do this: let with_in name f = let fd = open_in name in let v = try f () with exn -> close_in fd; raise exn in close_in fd; v
<flux> whops, scratch that
<flux> let with_in name f = let fd = open_in name in let v = try f fd with exn -> close_in fd; raise exn in close_in fd; v
<alexyk> flux: intersting! and now I see I'm past the point of EPIPE and all is well when I added close_in ic everywhere... I call external commands and then read/write results, somehow it's related
<flux> so which Unix.* functions do you use?
<alexyk> the commands are run with let in_channel = Unix.open_process_in command ... Unix.close_process_in in_channel
<alexyk> the reads/writes are done with ocaml's usual open/close_in/out
<alexyk> well I also increased the stack just to be sure :)
<flux> how do you open the fd you write into?
<alexyk> flux: open_out
<alexyk> flux: I don't write to pipes at all
<flux> alexyk, have you seen the backtrace?
<alexyk> flux: nope, I've restarted it already and it still works :)
<flux> alexyk, do you know how to get a backtrace?
<alexyk> flux: no, how?
<flux> alexyk, 1) compile with -g 2) export OCAMLRUNPARAM=b
<flux> 3) run
<alexyk> thx! will definitely try when I run into trouble
<flux> better do it beforehand, so you have it when you do run the first time :)
<alexyk> flux: how do I combine b with e.g. l=64M ?
<alexyk> is it colon-separated?
<flux> alexyk, I don't remember. likely comma-separated.
<alexyk> ok
middayc has joined #ocaml
mjrosenb has joined #ocaml
<mjrosenb> how do i use things from LWT in the repl?
<mjrosenb> and by things, i mean functions
<flux> mjrosenb, what is your question more exactly? how to bring them into scope? how to make constructed values to run?
<flux> I haven't used lwt, but for the latter Lwt_unix.run appears to be the key
fschwidom has joined #ocaml
<flux> how do you to val spawn : (unit -> 'a Lwt.t) -> 'a Lwt.t in Lwt?
snhmib has joined #ocaml
Kerris7 has quit []
Kerris7 has joined #ocaml
<alexyk> what's the modern take on calling C++ from ocaml? making it all like C?
<flux> that's one way
<flux> one other way, which I haven't traveled, is using Swik
<alexyk> flux: you mean swig?
<flux> ah, yes
<alexyk> it may be easier to rewrite everything in ocaml... :)
<alexyk> this is where I envy Boost.Python
<flux> well, there is hope
<flux> qtcaml apparently is coming up with some c++ binding generator
<flux> it would be interesting to try it with sfml
ygrek_ has joined #ocaml
seafood has quit []
middayc_ has joined #ocaml
<mjrosenb> flux: i want to bring them into scope
<flux> mjrosenb, #require "topfind";;
<flux> uh
<flux> #use "topfind";;
<flux> #require "lwt";;
<flux> and then refer to Lwt.xx, Lwt_unix.yy etc
<flux> (or "open" them if you wish)
<mjrosenb> sweet
<mjrosenb> is #require "topfind" mentioned anywhere on the inria site?
<flux> #require "topfind";; was wrong
<flux> but no, topfind is part of findlib
<mjrosenb> right.
Kerris7 has quit []
middayc has quit [Read error: 110 (Connection timed out)]
<mjrosenb> hrmm, i'm trying to find the types of various functions is Eliom
<mjrosenb> but i keep getting Reference to undefined global `XHTML'
<mjrosenb> i think my main issue is that i have no clue how to read the types that they specify here
<flux> I haven't really used it, and I don't have it installed here
<mjrosenb> well i'm mostly concerned about the types
<mjrosenb> i've dealt with sml and haskell before
<mjrosenb> but the types that are mentioned on that page are utter gibberish to me
pango has quit [Remote closed the connection]
pango has joined #ocaml
love-pingoo has joined #ocaml
<flux> like what?
<flux> mjrosenb, you mean [`Foo | `Bar]
<flux> ?
<mjrosenb> yeah, things like that
<mjrosenb> and
<flux> those are polymorphic variants. you can read about them from here: http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html
<mjrosenb> val body : ([< common ], [< block ], [> `Body ]) star
<flux> well, star is apparently a type that is parametrized by three other types
<flux> and those three types are all polymorphic variants
<mjrosenb> what are < and > ?
<flux> "The > and < inside the variant type shows that they may still be refined, either by defining more tags or allowing less."
<mjrosenb> fun.
<mjrosenb> labels seem to break a layer of syntax sugar that i'd preffer to not have broken
<flux> mjrosenb, hm?
<mjrosenb> let f x y = ... should be equivalet to let f = fun x -> fun y -> ...
<flux> well, let f ~x ~y = ... let f = fun ~x -> fun ~y -> ...
<flux> but you're right that currying doesn't quite work as nicely with labeled arguments
<flux> but labeled arguments have their places
gdmfsob has joined #ocaml
<flux> I didn't realize how nice it was that it's called Pcre.exec ~rex str instead of Pcre.exec rex str, until I saw a comment that he'd otherwise never remember the proper argument order
<flux> I might have issues with that too, but when I remember labeled arguments, it is simpelr
<flux> of course, Pcre might not be the best example, because it has overlapping definitions: Pcre.exec has both ~rex and ~pat, and nothing stops you from using both, even though you're supposed to use only one of them (?)
<flux> one other thing which I perhaps like even more is the optional arguments. this is one place where I think they've been implemented right.. (modulo some issue they cause ;-))
<mjrosenb> i think that there are better ways to implement optional arguments
<flux> which all involve modifying code that calls the code prior to adding the optional arguments?
<mjrosenb> what do you mean by 'modifying'?
<flux> well, one way that has been suggested would be do do f { default_f_args with optional_arg = 42 }
<flux> that would involve modifying existing code if they haven't taken any optional arguments before
<flux> mjrosenb, what other ways are you suggesting then?
<mjrosenb> so the system that i'm thinking of works alot better in haskell
<mjrosenb> where you have type classes
Yoric has quit [Remote closed the connection]
mishok13 has quit [Read error: 110 (Connection timed out)]
slash_ has joined #ocaml
<vixey> oh
<vixey> more on topic for #ocaml
middayc_ has quit [Read error: 60 (Operation timed out)]
middayc has joined #ocaml
ulfdoz has quit [Remote closed the connection]
ulfdoz has joined #ocaml
<flux> doesn't work for me
<flux> maybe it tries to open http connection to some port not allowed from work
<vixey> it's just this program from Coq turned into a java applet via ocaml, I thought that was cool
<flux> yeah, proven code is cool
<flux> but it's 6k+ lines for a sudoku solver :)
<flux> (or 4k for only Sudoku.v)
<flux> tried it locally. it maybe works, but it's really slow :)
<flux> yeah, works
<flux> the ocaml code doesn't come with it.. I doubt the user interface is extracted from Coq..
<flux> nice, it gives all solutions
dejj has joined #ocaml
<munga> I've written a small camlp4 parser. now I want to give it a whole file to read and parse I usually use Gram.parse_string to parse line by line. Is there a function to pass the entire file at one ? like Gram.parse_file ?
<munga> or shall I read the entire file into a buffer and then use parse_string ?
<munga> Gram.parse_string exp (Loc.mk fname) (input_file fname)
<munga> DUH
<munga> where input_file buffers the file into a string ...
pumpkin has quit [Remote closed the connection]
Stefan_vK has joined #ocaml
slash_ has quit [Client Quit]
Stefan_vK1 has quit [Read error: 110 (Connection timed out)]
middayc has quit []
fschwidom has quit [Remote closed the connection]
ppsmimou has quit ["Leaving"]
ppsmimou has joined #ocaml
asabil has quit ["Ex-Chat"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
AlexyK_ has joined #ocaml
AlexyK_ has quit [Client Quit]
love-pingoo has quit ["Connection reset by pear"]
willb has quit [Connection timed out]
marmotine has joined #ocaml
willb has joined #ocaml
fschwidom has joined #ocaml
Associat0r has quit []
fschwidom has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has joined #ocaml
robocop_ has joined #ocaml
<robocop_> Hello.
<robocop_> Have you ever had this error in ocaml ?
<robocop_> Parse error: [binding] expected after [opt_rec] (in [str_item])
<robocop_> Preprocessor error
<Yoric[DT]> Yes.
<Yoric[DT]> Can't remember exactly in which circumstances.
<robocop_> I think it's "camlp4o", because i use it.
<robocop_> but i don't understand why.
<robocop_> the error is detected on line 22 (let parser lexer...)
<Yoric[DT]> Well, it's certainly camlp4.
<robocop_> i don't understand why...
<Yoric[DT]> Oh, I got it.
<Yoric[DT]> With camlp4, "parser" is a reserved keyword.
<robocop_> Oh, okey.
<robocop_> Yes, you right, now is good. Thanks a lot.
gaja has quit ["Lost terminal"]
robocop_ has left #ocaml []
dabd has quit ["Ex-Chat"]
fbvortex has quit [Remote closed the connection]
Snark has joined #ocaml
robocop_ has joined #ocaml
jlouis has joined #ocaml
Kerris7 has joined #ocaml
fschwidom has joined #ocaml
mtrimpe has joined #ocaml
asabil has joined #ocaml
Smerdyakov has quit ["Leaving"]
Smerdyakov has joined #ocaml
gaja has joined #ocaml
alexyk has quit []
jdev has quit [Remote closed the connection]
jdev has joined #ocaml
alexyk has joined #ocaml
alexyk has quit []
alexyk has joined #ocaml
sebbu2 has joined #ocaml
sebbu has quit [Read error: 113 (No route to host)]
sebbu2 is now known as sebbu
Kerris7 has quit []
rpg_ has joined #ocaml
<rpg_> let rep f a n = if n < 0 then 0 else if n = 0 then a else begin f (rep f a (n-1)) end;;
<rpg_> whats wrong ? why does it go into a loop
<rpg_> oh
<rpg_> rec
<rpg_> hmm
<robocop_> the begin ...end is useless ?
<robocop_> no?
mbac has quit ["bbl"]
<rpg_> yeah
<olegfink> robocop_: they're actually parens.
<rpg_> but u know what
<rpg_> i always get syntax errors somehow
<olegfink> begin is equal to (, end is equal to )
<rpg_> so i figured thats the best way to always avoid them
<olegfink> so you may use them when you have to use ()
<rpg_> sometimes it works with begin end and it dont work with ()
<rpg_> weird
<olegfink> rpg_, example?
<rpg_> i dunno but it happened before
<rpg_> maybe its cos of addtitonal ;
mbac has joined #ocaml
robocop_ has left #ocaml []
hkBst has joined #ocaml
ygrek_ has quit [Remote closed the connection]
Jedai has quit [Read error: 110 (Connection timed out)]
Jedai has joined #ocaml
seafood has joined #ocaml
foo_ has joined #ocaml
<foo_> Hi! In module Graphics there is a function that draws image. But how to load it from a file?
<foo_> thanks
<foo_> I just thought I needn't use anything external
<olegfink> sure, write your own image reader and then fill the Graphics' color array array (which is what camlimages does)
Camarade_Tux has joined #ocaml
foo_ has quit ["Ex-Chat"]
marmotine has quit ["mv marmotine Laurie"]
christo_m has joined #ocaml
<christo_m> thelema, are u theree?
<christo_m> flux, are u there
<christo_m> mbac, how about you??
<christo_m> is anyone there?
<Optikal_> I am
<Optikal_> O_o
<christo_m> Optikal_ :)
<christo_m> Optikal_: http://rafb.net/p/q5eYB283.html
<christo_m> im trying to write a tail recursive function in the third part there
<christo_m> i know the first two are correct
<christo_m> Optikal_, something's wrong with the return type showever, i need (a` -> a`)
<christo_m> not (int -> int)
<Optikal_> 3rd function?
<christo_m> Optikal_, yes
<Optikal_> k
<christo_m> Optikal_, any ideas?
<Optikal_> It can't be 'a cause you are inferring it as int..
<christo_m> well i dont want it to be an int
<Optikal_> this is a function meant to be used on ints right?
<christo_m> f is a function im passing
<christo_m> well, its a function i pass a function, a value n (how many times the recursion should take place) and an argument a for the function f
<christo_m> so its like
<christo_m> f^n(a)
<Optikal_> WHat do you think the function signature should be?
<christo_m> i have no clue man, thats why im here
<christo_m> it should return units
<christo_m> hold on i can show you
<Optikal_> You don't want the n parameter to be forced as int I'm guessing
<christo_m> ('a->'a)->int->'a->'a
<christo_m> like this, and i think it should be an int
<Optikal_> Oh wait
<christo_m> a and n are both ints
<Optikal_> Yeah, you want n to int
<christo_m> f is a function, or 'a
<christo_m> unit rather
<Optikal_> ok
<Optikal_> I see
<Optikal_> you have iterate_aux n x
<Optikal_> and are calling iterate_aux n 0;;
<Optikal_> which means that x becomes an int..
<christo_m> x and a are synonymous i think
<christo_m> note that in line 28, i pass f of x which is a
<christo_m> back to the argument x in the iterate_aux function
<Optikal_> try in iterate_aux n a
<christo_m> wow, kk thanks it works
<christo_m> haha
Kerris7 has joined #ocaml
Kerris7_ has joined #ocaml
Kerris7 has quit [Read error: 54 (Connection reset by peer)]
<christo_m> Optikal_, still there man?
<christo_m> Optikal_, im trying to fix the return types for the other fucntions because they were of 'a ref, and i dont want any references
<christo_m> Optikal_, http://rafb.net/p/YySG3V91.html <- there's what I have so far, the second and third work fine but somethings wrong with the first (for loop iteration)
<Optikal_> take out the ; in done;
<christo_m> Optikal_, i have this val iterator_for : (unit -> 'a) -> int -> unit -> unit = <fun>
<christo_m> im not returning a value i think
<christo_m> do i need a temp value to store the contents of f a, becuase for loops dont return values or?
<Optikal_> why are you using an iterator, i'm just curious
<christo_m> assignment requirements.
<christo_m> needed a for loop, non tail recursion,and tail recursion
<christo_m> i still have to write the functions that are gonna be used by these
<Optikal_> Ah, yeah it looks like it
<christo_m> Optikal_, any ideas?
<olegfink> the second function looks suspiciously similar to the third.
<christo_m> olegfink, i hope not
<christo_m> ones supposed to be nontail, the latter, tail
<olegfink> how do you think a tail recursion differes from a non-tail one?
<christo_m> well, an auxilary function being introduced
<christo_m> id assume the two are pretty similar
<christo_m> except you carry the value rather than return it
<christo_m> anyway, somethings wrong with my first one :( can you help?
<olegfink> do you think that binding x to a and not carrying f along makes a non-tail recursion tail?
<christo_m> :(
<christo_m> i dont know..
<christo_m> i think using iterate_aux makes the original iterate_tail, tail
<christo_m> im assuming its wrong though
<olegfink> how come?
<christo_m> i dont know
<christo_m> i really dont man
<olegfink> iterate_tail is not recursive at all
<olegfink> neither is it tail recursive
<Optikal_> not sure how to do the for loop without references
<christo_m> hmm
<Optikal_> did they say you can't use references?
<christo_m> well it doesnt matter
<christo_m> so long as the return is the same
<christo_m> ('a->'a)->int->'a->'a <- like this
<olegfink> christo_m: read the definition of tail recursion, and then try to figure out which one function you have (tail or not) and how to write the other
<Optikal_> I doubt the spirit of the assignment is to get the signature to match
<Optikal_> =)
<christo_m> it is.
<olegfink> if you use [for] for updating a value, you obviously need to use references.
<christo_m> the program requirements specifically outline the signatures to have
Camarade_Tux has quit ["Leaving"]
<Optikal_> Yes, they want it to have that signature, but you could just have a garbage function and have the signatures match
<Optikal_> they want you to show that you know the difference between different kinds of loops
<christo_m> yes
<christo_m> well i know i have to use referneces
<christo_m> for a for loop, for loops dont return values
<olegfink> so use them!
<christo_m> from what i understand
<christo_m> okay im not sure how
<christo_m> without affecting the signatures
<olegfink> read the manual.
apples` has joined #ocaml
<olegfink> well, I admit ocaml doesn't have an equivalent of hoogle, but it shouldn't take long to find a function of type 'a ref -> a in the manual.
<christo_m> why cant you just tell me?
<christo_m> clearly its some mutator for references right?
<olegfink> # (!);;
<olegfink> - : 'a ref -> 'a = <fun>
<christo_m> ! is a selector.
<christo_m> it returns the value of the reference
<christo_m> for instance let x = ref 0 , !x should return 0
<olegfink> sure, isn't that what you're for?
<olegfink> right.
<christo_m> i guess..
<olegfink> you worried about types
<olegfink> this is the type cast you want.
<olegfink> you probably know about
<olegfink> # (:=);;
<olegfink> - : 'a ref -> 'a -> unit = <fun>
<christo_m> i cant have that.
<christo_m> thats the problem..
<christo_m> (sigh), whatever ill just do it
<olegfink> why can't you?
<christo_m> its not the right signature
<christo_m> its all good tho
mwhitney has quit ["WeeChat 0.2.6"]
<olegfink> what's wrong with its signature?
<olegfink> are you able to write a int -> int function which adds one to the expression and uses references?
<olegfink> s/expression/argument/
<rpg_> olegfink: i think he means that it will actually end up beegin int ref -> int
<rpg_> val rep : ('a ref -> 'a) -> int -> 'a -> 'a = <fun>
Snark has quit ["Ex-Chat"]
<rpg_> instead of val rep : ('a -> 'a) -> int -> 'a -> 'a = <fun>
<christo_m> i figured it out
<christo_m> thanks
Kerris7_ has quit [Read error: 54 (Connection reset by peer)]
hkBst has quit [Remote closed the connection]
Kerris7 has joined #ocaml
<olegfink> I don't see why, you have all the type convetrsions, both 'a -> 'a ref and 'a ref -> 'a
<Optikal_> let iterator_for f n a = let x = ref a; in for i = 0 to n do (x := (f !x)) done; !x;;
<Optikal_> is that what you came up with christo?
<christo_m> here ill show you
<christo_m> actually yea thats correct
_zack has joined #ocaml
<christo_m> i had it done like 10 mins ago my bad for not saying anything
<christo_m> im trying to get the rest of the assignment done
<christo_m> but here i posted the code: http://rafb.net/p/rs2xCR55.html
_zack has quit [Client Quit]
willb has quit [Read error: 110 (Connection timed out)]
<christo_m> whats wrong with this i don tge tit
<christo_m> get it*, like man, ocaml is so annoying with the syntax
<Optikal_> Do you know what begin and end do
<Optikal_> ?
<christo_m> theyre syntactic sugar for paranthesis?
<Optikal_> yep
<christo_m> look i have multiple statements in there
<christo_m> so what can i do
<Optikal_> try using in
slash_ has joined #ocaml
willb has joined #ocaml
<christo_m> Optikal_, i think i see what olegfink was saying about my third function
<christo_m> with my definition of the successor function (f(x) -> x + 1) im getting the same value for hte first two functions
<christo_m> but the third one is wrong
<christo_m> there it is, paste that in your interpreter, and then do iterator_for plus_maker 3 2;;
<christo_m> try for all of them, and you'll see hte lsat is wrong
<rpg_> (plus_maker 3) 2
<rpg_> let plus maker x = x + 1;;
<vixey> what
<Optikal_> that doesn't look like what the plus_maker function described on the pdf is supposed to do..
<rpg_> ure plus maker is 2 much extra
<vixey> rpg_: "ure" LOL
<rpg_> lol
<rpg_> bbl gotta go out for a while
<christo_m> rofl
<christo_m> Optikal_, whats wrong with it
<christo_m> thats what successor is defined as
<christo_m> apparently plus_maker builds upon itself with the iteration functions
<christo_m> not sure where to go with it, and still not sure why i have a diff return value for the last function there
<christo_m> rpg_, fixed lol, i was thinking too hard
<christo_m> its been a long dya, studying for statistics and MIPS asm at the same time
<Optikal_> Your plus_maer is int->int theirs is ((int -> int) -> int -> int -> int) -> int -> int -> int ...
<christo_m> Optikal_, im not sure how they got it to do that
<christo_m> why so many ints :(
<Optikal_> because you don't understand what they are asking I think
<christo_m> ah..
<christo_m> so what are they asking
<Optikal_> They want you to build a function that you pass an iterator to to build a 'plus iterator'
AlexyK_ has joined #ocaml
<christo_m> uhh
<Optikal_> let plus_maker i n:int a:int = i (fun x -> x + 1) n a;;
AlexyK_ has quit [Client Quit]
<Optikal_> something like that I think
willb has quit [Read error: 60 (Operation timed out)]
<Optikal_> err wait, that can't be it
<Optikal_> blah
<christo_m> lol
<christo_m> this is weird
<christo_m> definitely one of the more harder assignments :|
slash_ has quit [Client Quit]
<christo_m> Optikal_, im confused as to how the calling would take place
<christo_m> am i calling iterator_for wiht plus_maker as the function
<christo_m> or am i calling plus_maker with the iterator
<christo_m> its just confusing
<christo_m> oh wait i see
<christo_m> thats what (fun x -> x +1) is, thats the f argument
<christo_m> ur saying that wouldnt be it though?
jlouis has quit ["Leaving"]
<christo_m> Optikal_, i get an error with the n:int a:int stuff for the parameter
<christo_m> if i dont include them, then ocaml cant do any inference as to what those types are, so i get 'a->'b->'c etc
<rpg_> christo_m: that is wrong u might as well repace your unfction by (incr x)
<rpg_> its asking to do something else
<christo_m> soo
<christo_m> what do i do..
<rpg_> well lets take it word by word
<rpg_> plus_maker:
<rpg_> takes in : iteration
<christo_m> defines the addition function by iterating the successor function as shown before
<rpg_> builds : the addition function
<christo_m> okay so i set up i as the parameter for the iteration function
<rpg_> build the adition function by : iterating the suc() function
<christo_m> and suc() is defined by incr x lol
<rpg_> correct
<christo_m> so i should pass incr x to i
<christo_m> like i(incr x)
<rpg_> so it takes the iteration and applies it to the suc function
<rpg_> so its like saying iterate suc n a
<rpg_> = blah blah
<rpg_> something like that
<rpg_> bbl gotta go
<christo_m> NO
<christo_m> lol
<christo_m> im not sur ehow to define the function
<Yoric[DT]> Well, time to call it a night.
<Yoric[DT]> Cheers everyone.
Yoric[DT] has quit ["Ex-Chat"]
<olegfink> christo_m: just type the plus_maker explicitly
<olegfink> val plus_maker_with_stupid_types :
<olegfink> ((int -> int) -> int -> int -> int) -> int -> int -> int = <fun>
<christo_m> i can do that?
<christo_m> im confused..
<christo_m> let plus_maker i n a = i ((incr x) n a) ;;
<christo_m> thats what im thinking, probably wrong tho
Optikal__ has joined #ocaml
<Optikal__> did you figure out that function yet?
<olegfink> incr looks really strange in a functional expression
<olegfink> you probably mean succ
<christo_m> Optikal_, no
<christo_m> and yes
<Optikal__> can you give me the pdf link again?
<christo_m> however the succesor function is just x+1
<christo_m> x-> x+1
<olegfink> right, that's what you want
<olegfink> plus_maker iterate 2 3;;
<olegfink> - : int = 5
<christo_m> thats correct
willb has joined #ocaml
<christo_m> olegfink, you were right about my last function something is really wrong
<christo_m> it doesnt produce 5 like the others when given 2 3
<christo_m> look how many functions i have to write
<christo_m> its ridiculous
<christo_m> a lot of copying and pasting, voiding the DRY principle
<vixey> how do I write better ocaml?
<Optikal__> so it was let plus_maker i n a = i succ n a??
<christo_m> pretty much
<christo_m> vixey, im wondering the same thing
<christo_m> im so horrible with it...C okay, python okay, ocaml,..no
<Optikal__> strong static languages are a bit tough to get used to at first
<Optikal__> it gets easier
<christo_m> surprisingly i make less mistakes with C than ocaml, even though ocamls strict typing bullshit is supposed to help me avoid bugs
<christo_m> anyway, my apologies
<christo_m> im young, and stupid, and i just want to get this done
<Optikal__> what are you stuck on now?
<christo_m> figuring out whats wrong with the third function
<christo_m> the tail one
<Optikal__> link? (sorry, new puter)
<christo_m> oh
<Optikal__> the one with the function yeah =)
<christo_m> k not quite sure wat to do with that plusmaker crap either
<Optikal__> to get the signature to match?
<christo_m> well yeah, in general..
<christo_m> im still getting a b c's
<olegfink> write the types in the definition