CosmicRay has quit [Read error: 113 (No route to host)]
fab_ has joined #ocaml
fab__ has quit [Read error: 110 (Connection timed out)]
m3ga has joined #ocaml
Skal has quit ["Client exiting"]
smimou has quit ["bli"]
fab__ has joined #ocaml
whit is now known as whit|prom
fab_ has quit [Read error: 110 (Connection timed out)]
whit|prom has quit []
bzzbzz has joined #ocaml
Revision17 has joined #ocaml
pango_ has joined #ocaml
dylan has quit [Read error: 110 (Connection timed out)]
m3ga has quit ["disappearing into the sunset"]
pango has quit [Read error: 110 (Connection timed out)]
CosmicRay has joined #ocaml
descender has quit [Remote closed the connection]
descender has joined #ocaml
CosmicRay has left #ocaml []
Raziel has quit ["Yo soy goma. Tú eres cola."]
shirogane has joined #ocaml
__DL__ has joined #ocaml
Schmurtz has quit ["Plouf !"]
joshcryer has joined #ocaml
Snark has joined #ocaml
shirogane has quit [Remote closed the connection]
_JusSx_ has joined #ocaml
<
_JusSx_>
HI OCAML ppl
revision17_ has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
ld has joined #ocaml
<
ld>
hi, if I were to make an ocaml application that would need an embedded database, what database would you recommend ?
<
flux__>
there's ocaml-sqlite
<
flux__>
so maybe sqlite could fit your needs
<
flux__>
I don't think there are many real alternatives ;) (note, I have not used sqlite, only read about it)
<
ld>
isn't ocaml-sqlite alpha ?
<
flux__>
I don't know. it might still be sufficient for your needs, atleast there are some bindings and you wouldn't need to start from scratch
<
ld>
oh well... giving it a try :)
ld has quit ["leaving"]
Skal has joined #ocaml
smimou has joined #ocaml
_fab has joined #ocaml
fab__ has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
justinc has quit [Read error: 110 (Connection timed out)]
vodka-goo has joined #ocaml
bzzbzz has quit ["leaving"]
rq has quit ["Leaving"]
rq has joined #ocaml
_batdog is now known as batdog
vinz42 has joined #ocaml
vinz42 has quit [Remote closed the connection]
Mitar has joined #ocaml
<
Mitar>
is there anything wrong with this?
<
Mitar>
Pair (e1, e2) -> if is_list e2 then list_eval gamma env e1 e2 else error
<
Mitar>
i get Unbound value is_list
<
Mitar>
but i have later on let is_list = function _ -> false
<
Mitar>
(this is just an example which fails)
<
ski>
you should define things before using them (or define things mutually recursive)
<
Snark>
this is were you fail
<
Mitar>
hmm, it should be before this? is not dual pass compilation/
<
ski>
let only scopes over the things after it
<
ski>
let rec f x = ....
<
Mitar>
hm, so how can i declare two functions which call each other?
<
ski>
for recursive
<
ski>
let rec f x = ..g..
<
ski>
and g x = ..f..
<
ski>
for mutually recursive
<
Mitar>
and rec is_list = function << syntax error at rec
<
ski>
no second 'rec'
<
Mitar>
hmm, yes, of course
<
Mitar>
it is really a "strange" language
<
ski>
not so much different, compares to other functional programming languages
<
ski>
it's a different paradigm than imperative, of course
<
Mitar>
yes, to functional ... but from common languages it is
<
ski>
(Mitar : have you seen any other FPL ?)
<
ski>
s/common/imperative/ :)
<
ski>
Functional Programming Language
<
Mitar>
i am learning them, i took course Theory of programming languages
<
ski>
any Logic Programming, too ?
<
Mitar>
that is next semester
<
Mitar>
so we made MinML, MinHaskell, MinScheme
<
ski>
(Functional and Logic are often grouped under Declarative .. they are more similar to each other than to imperative)
<
ski>
Erlang is also an interesting language
<
Mitar>
i have to write MinScheme for homework in OCaml
<
ski>
10000s of threads ? no problem :)
<
Mitar>
we have decleration programming in second semester
<
Mitar>
10000s of threads, why?
<
ski>
it's designed for concurrency
<
Mitar>
yes, erlang ...
<
Mitar>
we just mentioned it
<
Mitar>
there is no time for everyhing
<
ski>
a functional core, and then threads comminicating with message-passing
<
Mitar>
Andrej Bauer is my profesor, if you know him
<
Mitar>
University of Ljubljana, Slovenia
<
Mitar>
(some people search in Russia)
<
ski>
(ignorant fools ;)
<
Mitar>
ok, back to work, chat is not good for work
<
Mitar>
what is a short cut to making a list: a :: b :: c :: []
<
vodka-goo>
[ a; b;c ]
<
Mitar>
what is difference between @ and ::
<
lispy>
@ will combine two lists, :: will comebine an element and a list
<
Mitar>
is there any faq for such questions?
<
lispy>
well, the type of each function could answer it :)
<
lispy>
i don't know of an faq but that doesn't mean it doesn't exist :)
<
Mitar>
yes, type, i have forgotten about that
<
Mitar>
build_args vars e =
<
Mitar>
List.combine vars e
<
Mitar>
with Invalid_argument -> error
<
Mitar>
The constructor Invalid_argument expects 1 argument(s), but is here applied to 0 argument(s)
<
pango_>
exception Invalid_argument of string
<
pango_>
if you want to match any Invalid_argument exception, you must either use a free variable (Invalid_argument s), or the universal pattern _
<
pango_>
(Invalid_argument _)
<
pango_>
or match specifically Invalid_argument "List.combine"
<
Mitar>
i am still searching for documentation ...
<
Mitar>
yes, what would List.combine as a parameter in Invalid_argument?
<
Mitar>
"List.combine"?
<
pango_>
# List.combine [1] [1;2] ;;
<
pango_>
Exception: Invalid_argument "List.combine".
<
Mitar>
this is sooo useful
<
Mitar>
i am getting a grip with ocaml slowly
<
pango_>
there's not so many error conditions that can happen one typing is correct ;)
<
pango_>
s/one/once/
<
Mitar>
but i am a Perl guy ...
<
Mitar>
this is guite a difference for me
<
pango_>
I mainly learned ocaml using "developing applications with objective caml"
__DL__ has quit [Remote closed the connection]
<
pango_>
but I still consider it a great book
<
pango_>
btw, List.combine is written in ocaml, so there's always the solution to look at the source (list.ml in library directory)
<
pango_>
straightforward non tail-recursive implementation btw
<
Mitar>
is this good or bad?
<
Mitar>
(i think that non tail-recursive is bad)
<
pango_>
well, it doesn't scale to very large lists... stack overflow problems
<
Mitar>
yes, why they do not use for loop? :-)
<
pango_>
that function could have been written tail-recursive without resorting to imperative flow control structures...
<
Mitar>
yes, and why it is not?
revision17_ has quit [Remote closed the connection]
<
pango_>
non tail-recursive is ok for small lists, and code is a bit more readable
Revision17 has joined #ocaml
<
Mitar>
how can i sum all ints in a list?
<
Mitar>
fold_left + list?
<
pango_>
List.fold_left (+) 0 myintlist
<
Snark>
let rec sum_int_list l = match l with [] -> 0 | car :: cdr -> car + (sum_int_list cdr)
<
Mitar>
i like fold solution better
<
Mitar>
hm, why (+)
<
Mitar>
i see that it does not for without
<
Snark>
(+) to mean the function
<
Snark>
and 0 to give the seed
<
pango_>
# List.fold_left ;;
<
pango_>
- : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a = <fun>
<
Mitar>
ehm, this is too unreadable for me
<
pango_>
you'll have to learn to read it then ;)
<
Mitar>
it means: we have a function which maps a' to b' and back to a'?
<
Mitar>
and than this function we use on a'?
<
pango_>
yes, 'a and 'b are type variables
<
Mitar>
i have to think about types and not values here
<
pango_>
signature does only give information about expected types, but it's often enough to understand what a function does
<
pango_>
(as you did)
<
Mitar>
'a-s does not mean the same value but the same type
<
Mitar>
i have to keep this in mind
<
Mitar>
if i have a type Int of int
<
Mitar>
how can i get int out of this?
<
Mitar>
so that i can + on it?
<
pango_>
I suppose you have a sum type, like type int_or_string = Int of int | String of string
<
pango_>
then you can write
<
pango_>
let int_value ios =
<
pango_>
match ios with
<
pango_>
| Int i -> i
<
pango_>
| _ -> invalid_arg "int_value"
<
Mitar>
you correctly assume
<
Mitar>
is there difference between Int i -> Int i and Int i -> i
<
pango_>
Int i is of type int_or_string, in that example
<
pango_>
while i in just an int
<
pango_>
val int_value : int_or_string -> int = <fun>
Rickdangerous has joined #ocaml
<
Mitar>
hm: This expression has type Minscheme.expr but is here used with type int
<
Mitar>
but expr is union of Int which is int
<
Mitar>
and i get this in and to_int = function
<
Mitar>
Int e -> Int e
<
Mitar>
| _ -> error
<
Mitar>
and it works
<
pango_>
you're getting fooled by your own notation, Int e is not an integer
<
Snark>
not strange
<
pango_>
since it's build by the Int constructor, it's type is the sum type
<
pango_>
had you chosen expr = Foo of int | Bar of string, maybe things would have been more obvious
<
pango_>
Foo e is an expr, not an integer
<
Mitar>
yes, but why can than ocaml converts to int ?
<
Mitar>
i would understand if i had to write Int e -> int e
<
Snark>
e is of type int
<
pango_>
it does not "convert", it does deconstruction thru pattern matching
<
Snark>
there's no need to make it explicit
<
Mitar>
hm, Int is just a alias for int
<
Mitar>
aggh: List.fold_left (*) 0 << it takes it as a comment
<
pango_>
Int is an expr constructor with an int parameter, so e has to be a int
<
Mitar>
(and yes, there should be 1 and not 0)
<
pango_>
you must write ( * ) with spaces
<
pango_>
because (* indeed denotes the start of a comment
<
Mitar>
i will go to my friends now, to help them with this assigment
<
Mitar>
i know, but the solution for this is simple
<
Mitar>
thanks again for all your help
Rickdangerous has left #ocaml []
Snark has quit ["Leaving"]
<
pango_>
Mitar: you could have written e:int, but it's not necessary, ocaml type inference already determined that
Raziel has joined #ocaml
Raziel has quit [Client Quit]
Raziel has joined #ocaml
zigong has joined #ocaml
_JusSx_ has quit [Client Quit]
Skal has quit ["Client exiting"]
bzzbzz has joined #ocaml
zigong has quit [Remote closed the connection]
whit has joined #ocaml