Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

ocaml_beginners · Ocaml Beginners

The Yahoo! Groups Product Blog

Check it out!

Group Information

? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Messages 8590 - 8619 of 13890   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#8590 From: Peter Halacsy <peter@...>
Date: Sat Sep 1, 2007 1:00 pm
Subject: piping ocamllex
halacsyp
Send Email Send Email
 
hello!

i'd like to write several ocamllex filters that work in a pipe. In
natural language processing it's a common solution to write more flex
filters, or sed script to tokenize a text. Is it efficient to write a
buffer from an ocamllex module and retokenize the content of the
buffer with an other ocamllex program? Here is a very old tokenizer
using this idea (but using stdin an out and uniex pipes)
http://aune.lpl.univ-aix.fr/projects/multext/MtSeg/MSG1.tools.html

peter

#8591 From: Fabrice Marchant <fabrice.marchant@...>
Date: Sat Sep 1, 2007 10:17 pm
Subject: Swapping parameters
fabrice.marc...
Send Email Send Email
 
Hi !

Sometimes it is maybe useful to do this :

let swap_parameters f x y = f y x

   But what could be a good choice for an operator name ?
(|<->) ? Maybe something else is currently used ?

let (|<->) f x y = f y x

As an example of use :

let foo x y = g x y z

could be rewritten :

let bar x = g |<-> x z

   Ugly enough... And maybe the things do not look like very simplified ( we got
a "|<->" instead of two "y" and the code seems less readable).
I wonder if the "y" parameter suppression is'nt however helpful because it is
functional / abstract a degree further.
   And so more easily reusable ?

  Please what is normally used to swap parameters ?

Thanks,

Fabrice
----------------------
Des mécanos, un mec...

#8592 From: William Neumann <wneumann@...>
Date: Sun Sep 2, 2007 7:12 am
Subject: Re: "ocaml_beginners"::[] Swapping parameters
scoey13
Send Email Send Email
 
On Sep 1, 2007, at 5:17 PM, Fabrice Marchant
<fabrice.marchant@...> wrote:

> Please what is normally used to swap parameters

Haskell just calls this function 'flip' in its prelude.  I find that
to be a good name.

William D. Neumann

#8593 From: Fabrice Marchant <fabrice.marchant@...>
Date: Sun Sep 2, 2007 6:43 am
Subject: Re: "ocaml_beginners"::[] Swapping parameters
fabrice.marc...
Send Email Send Email
 
On Sun, 2 Sep 2007 02:12:53 -0500
William Neumann <wneumann@...> wrote:

> Haskell just calls this function 'flip' in its prelude.  I find that
> to be a good name.

   Thanks a lot William !

So, if Haskell hasn't used any operator, probably we do not need too.
All right for 'flip' : far shorter than 'swap_parameters'.

   The list of usually defined operators I've met remains short :

let ( |> ) x f = f x
let ( << ) f g x = f(g x)

Recently seen this on the list :
let ( @ ) f x = f x;;
( for Haskell $ )

and heard about ( >> ) but do not know what it means.

  Best,

Fabrice

#8594 From: Matthieu Dubuget <matthieu.dubuget@...>
Date: Sun Sep 2, 2007 10:23 am
Subject: Re: "ocaml_beginners"::[] Swapping parameters
dubuget
Send Email Send Email
 
Fabrice Marchant a écrit :
>
> On Sun, 2 Sep 2007 02:12:53 -0500 William Neumann
> <wneumann@... <mailto:wneumann%40cs.unm.edu>> wrote:
>
>> Haskell just calls this function 'flip' in its prelude. I find that
>>  to be a good name.
>
> Thanks a lot William !
>
> So, if Haskell hasn't used any operator, probably we do not need too.
>  All right for 'flip' : far shorter than 'swap_parameters'.
>
> The list of usually defined operators I've met remains short :
>
> let ( |> ) x f = f x let ( << ) f g x = f(g x)
>
> Recently seen this on the list : let ( @ ) f x = f x;; ( for Haskell
> $ )
>
> and heard about ( >> ) but do not know what it means.
>
> Best,
>
> Fabrice

Hello,

The following text is stolen from F# manual pages
(http://research.microsoft.com/fsharp/manual/quicktour.aspx).
Hoping this will help?
Salutations

Matt


The following two important operators are defined in *MLLib.Pervasives*:

     let (|>) x f = f x

Pipeline operator

     let (>>) f g x = g(f x)

     Function composition operator

These are very important in F# code and will be used in many samples you
see. They are used to pipeline and compose functions. For example:

         let allMembers =
           System.AppDomain.CurrentDomain.GetAssemblies()
           |> Array.to_list |> List.map (fun a -> a.GetTypes()) |>
Array.concat
           |> Array.to_list |> List.map (fun ty -> ty.GetMembers()) |>
Array.concat;;





[Non-text portions of this message have been removed]

#8595 From: Fabrice Marchant <fabrice.marchant@...>
Date: Sun Sep 2, 2007 8:31 am
Subject: Calling 'equal' with different hash values !?
fabrice.marc...
Send Email Send Email
 
Hi !

  Using J.C. Filliâtre Hashset - an adapted version from Hashtbl -,
my program output is correct.

   I was surprised to discover that the "equal" compare function I provided to
Hashset module was called for values that do not share the same hash ! ?

   I thought to have understood since a long time that :

different hash values ->
no clash, not in same bucket ->
no need to perform the slow deep 'equal' test

   So I've necessarily a bug ?
Please could you confirm this ?

(Here is the program, but they are several pages and maybe they aren't useful to
be sure something goes wrong.
http://fabrice.marchant.free.fr/OCamlCode/n-edges/
)

Thanks

#8596 From: Fabrice Marchant <fabrice.marchant@...>
Date: Mon Sep 3, 2007 7:40 pm
Subject: Re: "ocaml_beginners"::[] Swapping parameters
fabrice.marc...
Send Email Send Email
 
On Sun, 02 Sep 2007 12:23:30 +0200
Matthieu Dubuget <matthieu.dubuget@...> wrote:

> Hello,
>
> The following text is stolen from F# manual pages
> (http://research.microsoft.com/fsharp/manual/quicktour.aspx).
> Hoping this will help?
> Salutations
>
> Matt
>
>
> The following two important operators are defined in *MLLib.Pervasives*:
>
>     let (|>) x f = f x
>
> Pipeline operator
>
>     let (>>) f g x = g(f x)
>
>     Function composition operator
>
> These are very important in F# code and will be used in many samples you
> see. They are used to pipeline and compose functions. For example:
>
>         let allMembers =
>           System.AppDomain.CurrentDomain.GetAssemblies()
>           |> Array.to_list |> List.map (fun a -> a.GetTypes()) |>
> Array.concat
>           |> Array.to_list |> List.map (fun ty -> ty.GetMembers()) |>
> Array.concat;;

    Thanks a lot Matt for (>>) operator name and definition !

MS speaks about many examples : I do not see anything about (>>).
I simply notice we have :
(>>) = flip (<<)
There are things for everybody, for semitic languages too.

  Cheers,

Fabrice
-----------------------------------------------------------------------------
Pesticides -> plus d'abeilles -> plus de pollenisation -> la fin des haricots

#8597 From: "bobshibby36" <bobshibby36@...>
Date: Wed Sep 5, 2007 9:38 am
Subject: Can't verify object data ?
bobshibby36
Send Email Send Email
 
Hi,

I am working with an object :

     class state_view =
       object
	 val mutable expanded : bool = true;
	 val mutable links_opt : (string * int) list option = None;
	 val mutable locals_opt : Ext.t option = None;
	 val mutable links_options : Context.links_option list = [];
	 val mutable links_sort_fun : links_sort_fun = sort_by_count;

	 method expanded = expanded
	 method links_opt = links_opt
	 method locals_opt = locals_opt
	 method links_options = links_options
	 method links_sort_fun = links_sort_fun

	 method set_expanded b = expanded <- b
	 method set_links_opt l = links_opt <- l
	 method set_locals_opt ext = locals_opt <- ext
	 method set_links_options options = links_options <- options
	 method set_links_sort_fun f = links_sort_fun <- f

	 method copy = {< links_opt = None; locals_opt = None >}
       end

the "links_sort_fun" is a function. I can put "sort_by_count" or
"sort_by_feature" into it with the function "set_links_sort_fun
(sort_by_feature/sort)"

I need to know what is in this variable. So I verify but if I write :

if (links_sort_fun = sort_by_feature) then ....

It's compiled but I got an execution error.

If I write :

match links_sort_fun with
         sort_by_count -> ....
|       sort_by_feature ->....

I ALWAYS match sort_by_count even if I would be supposed to have
"sort_by_feature". And I got a warning telling me that the case line X
(X is the line of | sort_by_feature -> ...) is unused :s
Furthermore If I write

match links_sort_fun with
        blbibljljlmqdsjfmqjf ->  ...
| ....

That's the same thing, I always match blbibljljlmqdsjfmqjf ...

So how can I know what is in this variable ?

#8598 From: "bobshibby36" <bobshibby36@...>
Date: Wed Sep 5, 2007 9:43 am
Subject: Re: Can't verify object data ?
bobshibby36
Send Email Send Email
 
OK I found out the way of doing this

if links_sort_fun==sort_by_count ...

It's works. But why my match did not work too?

--- In ocaml_beginners@yahoogroups.com, "bobshibby36"
<bobshibby36@...> wrote:
>
> Hi,
>
> I am working with an object :
>
>     class state_view =
>       object
>  val mutable expanded : bool = true;
>  val mutable links_opt : (string * int) list option = None;
>  val mutable locals_opt : Ext.t option = None;
>  val mutable links_options : Context.links_option list = [];
>  val mutable links_sort_fun : links_sort_fun = sort_by_count;
>
>  method expanded = expanded
>  method links_opt = links_opt
>  method locals_opt = locals_opt
>  method links_options = links_options
>  method links_sort_fun = links_sort_fun
>
>  method set_expanded b = expanded <- b
>  method set_links_opt l = links_opt <- l
>  method set_locals_opt ext = locals_opt <- ext
>  method set_links_options options = links_options <- options
>  method set_links_sort_fun f = links_sort_fun <- f
>
>  method copy = {< links_opt = None; locals_opt = None >}
>       end
>
> the "links_sort_fun" is a function. I can put "sort_by_count" or
> "sort_by_feature" into it with the function "set_links_sort_fun
> (sort_by_feature/sort)"
>
> I need to know what is in this variable. So I verify but if I write :
>
> if (links_sort_fun = sort_by_feature) then ....
>
> It's compiled but I got an execution error.
>
> If I write :
>
> match links_sort_fun with
>         sort_by_count -> ....
> |       sort_by_feature ->....
>
> I ALWAYS match sort_by_count even if I would be supposed to have
> "sort_by_feature". And I got a warning telling me that the case line X
> (X is the line of | sort_by_feature -> ...) is unused :s
> Furthermore If I write
>
> match links_sort_fun with
>        blbibljljlmqdsjfmqjf ->  ...
> | ....
>
> That's the same thing, I always match blbibljljlmqdsjfmqjf ...
>
> So how can I know what is in this variable ?
>

#8599 From: Vincent Aravantinos <vincent.aravantinos@...>
Date: Wed Sep 5, 2007 10:07 am
Subject: Re: "ocaml_beginners"::[] Re: Can't verify object data ?
vincent.arav...
Send Email Send Email
 
Le 5 sept. 07 à 11:43, bobshibby36 a écrit :

> OK I found out the way of doing this
>
> if links_sort_fun==sort_by_count ...
>
> It's works. But why my match did not work too?
>
>> match links_sort_fun with
>>         sort_by_count -> ....
>> |       sort_by_feature ->....

-> this is almost the same as :

match links_sort_fun with
x -> ...
| y -> ...

(except you should substitute references to sort_by_count/
sort_by_feature with x/y)

or :
match links_sort_fun with
_ -> ...
| _ -> ...

see the semantics ? the two branches catch any case.

ie when put in the left member of a case, a variable is considered as
a new variable (the compiler forget its previous meaning).

This is a frequent beginner error and someone explained it very well
and concisely recently in this thread but I can't find it (think it
was William Neuman).

Hope it's clear...

--
Vincent Aravantinos
PhD Student - LIG - CAPP Team

#8600 From: "bobshibby36" <bobshibby36@...>
Date: Wed Sep 5, 2007 10:54 am
Subject: "ocaml_beginners"::[] Re: Can't verify object data ?
bobshibby36
Send Email Send Email
 
Ok, fine I got it ;)

--- In ocaml_beginners@yahoogroups.com, Vincent Aravantinos
<vincent.aravantinos@...> wrote:
>
>
> Le 5 sept. 07 à 11:43, bobshibby36 a écrit :
>
> > OK I found out the way of doing this
> >
> > if links_sort_fun==sort_by_count ...
> >
> > It's works. But why my match did not work too?
> >
> >> match links_sort_fun with
> >>         sort_by_count -> ....
> >> |       sort_by_feature ->....
>
> -> this is almost the same as :
>
> match links_sort_fun with
> x -> ...
> | y -> ...
>
> (except you should substitute references to sort_by_count/
> sort_by_feature with x/y)
>
> or :
> match links_sort_fun with
> _ -> ...
> | _ -> ...
>
> see the semantics ? the two branches catch any case.
>
> ie when put in the left member of a case, a variable is considered as
> a new variable (the compiler forget its previous meaning).
>
> This is a frequent beginner error and someone explained it very well
> and concisely recently in this thread but I can't find it (think it
> was William Neuman).
>
> Hope it's clear...
>
> --
> Vincent Aravantinos
> PhD Student - LIG - CAPP Team
>

#8601 From: Zheng Li <li@...>
Date: Wed Sep 5, 2007 11:27 am
Subject: Re: Unable to fold this
li@...
Send Email Send Email
 
Hi,

There are several issues:

Fabrice Marchant <fabrice.marchant@...> writes:
> Please imagine you have to try all the cases of integer
   intervals product.
> For this example, we choose min element = 1.
> We simply nest three loops :*)
> let try_cases max1 max2 max3 f =
> for i1 = 1 to max1 do
> for i2 = 1 to max2 do
> for i3 = 1 to max3 do
> f i1 i2 i3
> done
> done
> done
> In the related question - "How to properly write this ?" - Rich
   explained,
> about my erroneous folding attempt,
> that a type problem occured and prevent to write things the way
   I tried.
> Please how to use an integer list for max elements ?

* First, a more generic implementation (you can specify both lower
bound and higher bound) is given below:
------------8<-----------------------------8<------------------------------
open List
let permute : (int * int) list -> int list list =
   let rec aux res tmp = function
     | [] -> res
     | (a,b) :: t when a <= b ->
         let tmp' = fold_left (fun l x -> (a :: x) :: l) tmp res in
         aux res tmp' ((a + 1, b) :: t)
     | _  :: t -> aux (rev tmp) [] t in
   function [] -> []  | l -> aux [[]] [] (rev l)

# permute [];;
- : int list list = []
# permute [1,4];;
- : int list list = [[1]; [2]; [3]; [4]]
permute [(1,4); (12,15); (5,6); (21,22)];;
- : int list list =
[[1; 12; 5; 21]; [1; 12; 5; 22]; [1; 12; 6; 21]; [1; 12; 6; 22];
  [1; 13; 5; 21]; [1; 13; 5; 22]; [1; 13; 6; 21]; [1; 13; 6; 22];
  [1; 14; 5; 21]; [1; 14; 5; 22]; [1; 14; 6; 21]; [1; 14; 6; 22];
  [1; 15; 5; 21]; [1; 15; 5; 22]; [1; 15; 6; 21]; [1; 15; 6; 22];
  [2; 12; 5; 21]; [2; 12; 5; 22]; [2; 12; 6; 21]; [2; 12; 6; ...];
  ...]
--------------8<----------------------------8<-----------------------------

* It would be much easier if you don't care 1) tail recursion 2)
row-major ordering. In such a case, just the combination of a few
map and flatten will get it done. The easiest way is probably
using the list comprehension introduced by the new Camlp4.

* I once post a survey on the official mailing list [1] on both
combinatorial and iterative approaches to solve the problem.

* Moreover, there is a pitfall here:
   - If your data space is small, you shouldn't bother to write a
tail-recursive solution. The little running overhead (if any)
doesn't worth the burden of complicating your code.
   - On the other hand, if your data space is large enough, even
with tail recursion, your combinatorial computation may still
consume a lot of time and memory. In such cases, you should really
consider to use the iterative approach instead, unless you really
need to produce and save the output data all at once, rather
iteratively manipulate them.
   - So the living space of a combinatorial tail-recursive solution
is actually rather small.

HTH.

[1]
http://caml.inria.fr/pub/ml-archives/caml-list/2007/03/44de9b27bfaf73265501dafcf\
be6b78c.en.html

#8602 From: Johann Spies <jspies@...>
Date: Wed Sep 5, 2007 1:42 pm
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
jspies@...
Send Email Send Email
 
On Fri, Aug 31, 2007 at 11:20:09PM +0100, Richard Jones wrote:

> Not hugely useful because this just shows that make fails. You need
> to strace the actual program which fails -- try 'strace -f' and
> untangle the failing program from that.

Will this help:

[pid 29893] mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b0a3d099000
[pid 29893] read(4, "127.0.0.1\tlocalhost\n127.0.1.1\twe"..., 4096) =
289
[pid 29893] read(4, "", 4096)           = 0
[pid 29893] close(4)                    = 0
[pid 29893] munmap(0x2b0a3d099000, 4096) = 0
[pid 29893] getrusage(RUSAGE_SELF, {ru_utime={0, 16001}, ru_stime={0,
8000}, ...}) = 0
[pid 29893] getrusage(RUSAGE_CHILDREN, {ru_utime={0, 0}, ru_stime={0,
0}, ...}) = 0
[pid 29893] getppid()                   = 29892
[pid 29893] uname({sys="Linux", node="werkesel", ...}) = 0
[pid 29893] socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
[pid 29893] connect(4, {sa_family=AF_INET, sin_port=htons(5432),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
[pid 29893] fcntl(4, F_GETFD)           = 0
[pid 29893] fcntl(4, F_SETFD, FD_CLOEXEC) = 0
[pid 29893] lseek(4, 0, SEEK_CUR)       = -1 ESPIPE (Illegal seek)
[pid 29893] lseek(4, 0, SEEK_CUR)       = -1 ESPIPE (Illegal seek)
[pid 29893] write(4, "\0\0\0\35\0\3\0\0user\0js\0database\0js\0\0",
29) = 29
[pid 29893] read(4, "R\0\0\0\f\0\0\0\5s\354p\374", 4096) = 13
[pid 29893] write(4, "p\0\0\0(md5d773a278418fa13717d2c01d"..., 41) =
41
[pid 29893] read(4, "E\0\0\0\\SFATAAL\0C28000\0Mpassword au"..., 4096)
= 93
[pid 29893] read(4, "", 4096)           = 0
[pid 29893] close(3)                    = 0
[pid 29893] write(2, "File \"\", line 0, characters 0-1:"..., 65File
"", line 0, characters 0-1:
Uncaught exception: End_of_file
) = 65
[pid 29893] write(2, "Uncaught exception: End_of_file\n", 32Uncaught
exception: End_of_file
) = 32
[pid 29893] exit_group(2)               = ?
Process 29892 resumed
Process 29893 detached

Regards
Johann

--
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

      "He hath not dealt with us after our sins; nor rewarded
       us according to our iniquities. For as the heaven is
       high above the earth, so great is his mercy toward
       them that fear him. As far as the east is from the
       west, so far hath he removed our transgressions from
       us."     Psalms 103:10-12

#8603 From: "darioteixeira" <darioteixeira@...>
Date: Wed Sep 5, 2007 2:44 pm
Subject: A Brief Introduction to PG'OCaml
darioteixeira
Send Email Send Email
 
Dear OCaml users,

I have been using the PG'OCaml library for some time now, and I have
written some notes that document various aspects of the library.
Judging from the recent messages in the Ocaml-beginners mailing-list,
there's an active interest in this library out there.  I have thus
decided to expand on those notes and to make them publicly available.

The document, title "A Brief Introduction to PG'OCaml" can be found at
the following address: http://dario.dse.nl/projects/pgoctut/
(A summary of its contents is attached to the end of this message).

Suggestions/corrections are of course welcome!

Kind regards,
Dario Teixeira

___________________________________________________________________________

PG'OCaml, by Richard W. M. Jones, provides an interface to PostgreSQL
databases for OCaml applications. It uses Camlp4 to extend the OCaml
syntax, enabling one to directly embed SQL statements inside the OCaml
code. Moreover, it uses the describe feature of PostgreSQL to obtain
type information about the database. This allows PG'OCaml to check at
compile-time  if the programme is indeed consistent with the database
structure. This type-safe database access is the primary advantage that
PG'OCaml has over other PostgreSQL bindings for OCaml.

Unfortunately, PG'OCaml is rather lacking on the documentation
front. This document aims to fill that gap, by providing an overview
of the capabilities of the library, usage examples, and solutions to
potential pitfalls. Moreover, it also addresses the installation of
PG'OCaml, how to compile programmes that make use of the library, and the
correspondence between PostgreSQL data types and their OCaml counterparts.
___________________________________________________________________________

#8604 From: Peng Zang <peng.zang@...>
Date: Wed Sep 5, 2007 3:47 pm
Subject: Re: "ocaml_beginners"::[] Re: Can't verify object data ?
peng.zang@...
Send Email Send Email
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you like matches you can use a guard to get the same effect.  Eg.

match links_sort_fun with
   | thefun when thefun == sort_by_count ->  ... something...
   | theotherfun ->

Peng

On Wednesday 05 September 2007 05:43, bobshibby36 wrote:
> OK I found out the way of doing this
>
> if links_sort_fun==sort_by_count ...
>
> It's works. But why my match did not work too?
>
> --- In ocaml_beginners@yahoogroups.com, "bobshibby36"
>
> <bobshibby36@...> wrote:
> > Hi,
> >
> > I am working with an object :
> >
> >     class state_view =
> >       object
> >  val mutable expanded : bool = true;
> >  val mutable links_opt : (string * int) list option = None;
> >  val mutable locals_opt : Ext.t option = None;
> >  val mutable links_options : Context.links_option list = [];
> >  val mutable links_sort_fun : links_sort_fun = sort_by_count;
> >
> >  method expanded = expanded
> >  method links_opt = links_opt
> >  method locals_opt = locals_opt
> >  method links_options = links_options
> >  method links_sort_fun = links_sort_fun
> >
> >  method set_expanded b = expanded <- b
> >  method set_links_opt l = links_opt <- l
> >  method set_locals_opt ext = locals_opt <- ext
> >  method set_links_options options = links_options <- options
> >  method set_links_sort_fun f = links_sort_fun <- f
> >
> >  method copy = {< links_opt = None; locals_opt = None >}
> >       end
> >
> > the "links_sort_fun" is a function. I can put "sort_by_count" or
> > "sort_by_feature" into it with the function "set_links_sort_fun
> > (sort_by_feature/sort)"
> >
> > I need to know what is in this variable. So I verify but if I write :
> >
> > if (links_sort_fun = sort_by_feature) then ....
> >
> > It's compiled but I got an execution error.
> >
> > If I write :
> >
> > match links_sort_fun with
> >         sort_by_count -> ....
> >
> > |       sort_by_feature ->....
> >
> > I ALWAYS match sort_by_count even if I would be supposed to have
> > "sort_by_feature". And I got a warning telling me that the case line X
> > (X is the line of | sort_by_feature -> ...) is unused :s
> > Furthermore If I write
> >
> > match links_sort_fun with
> >        blbibljljlmqdsjfmqjf ->  ...
> >
> > | ....
> >
> > That's the same thing, I always match blbibljljlmqdsjfmqjf ...
> >
> > So how can I know what is in this variable ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.2 (GNU/Linux)

iD8DBQFG3s+rfIRcEFL/JewRAjrkAJ925sLV+PTHv1YZj6WeJEm972yPlQCdGglD
chPlhkbYyndMT4dn0r3GWH8=
=CUrt
-----END PGP SIGNATURE-----

#8605 From: Richard Jones <rich@...>
Date: Thu Sep 6, 2007 9:11 am
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
rwmjones
Send Email Send Email
 
On Wed, Sep 05, 2007 at 03:42:26PM +0200, Johann Spies wrote:
> [pid 29893] read(4, "E\0\0\0\\SFATAAL\0C28000\0Mpassword au"..., 4096)

That's the error ...  If you run strace with the `-s' option you'll be
able to see more of it.

Rich.

--
Richard Jones
Red Hat

#8606 From: Johann Spies <jspies@...>
Date: Thu Sep 6, 2007 9:39 am
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
jspies@...
Send Email Send Email
 
On Thu, Sep 06, 2007 at 10:11:57AM +0100, Richard Jones wrote:
> On Wed, Sep 05, 2007 at 03:42:26PM +0200, Johann Spies wrote:
> > [pid 29893] read(4, "E\0\0\0\\SFATAAL\0C28000\0Mpassword au"..., 4096)
>
> That's the error ... If you run strace with the `-s' option you'll be
> able to see more of it.
>
Thanks.  I am learning...

But: I can use psql with the same environmental variables  ( psql -h
$PGHOST -d $PGDATABASE -U $PGUSER -p $PGPORT --password) and log in
with the same password.  Why not using pgocaml?

Regards
Johann
--
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

      "Behold, I stand at the door, and knock; if any man
       hear my voice, and open the door, I will come in to
       him, and will sup with him, and he with me."
                                    Revelation 3:20

#8607 From: Richard Jones <rich@...>
Date: Thu Sep 6, 2007 11:54 am
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
rwmjones
Send Email Send Email
 
On Thu, Sep 06, 2007 at 11:39:18AM +0200, Johann Spies wrote:
> On Thu, Sep 06, 2007 at 10:11:57AM +0100, Richard Jones wrote:
> > On Wed, Sep 05, 2007 at 03:42:26PM +0200, Johann Spies wrote:
> > > [pid 29893] read(4, "E\0\0\0\\SFATAAL\0C28000\0Mpassword au"..., 4096)
> >
> > That's the error ... If you run strace with the `-s' option you'll be
> > able to see more of it.
> >
> Thanks.  I am learning...
>
> But: I can use psql with the same environmental variables  ( psql -h
> $PGHOST -d $PGDATABASE -U $PGUSER -p $PGPORT --password) and log in
> with the same password.  Why not using pgocaml?

I've no idea, but I guess the error message will tell you.

Rich.

--
Richard Jones
Red Hat

#8608 From: "scheinandrew" <andrew@...>
Date: Fri Sep 7, 2007 1:53 am
Subject: custom ocaml toplevel
scheinandrew
Send Email Send Email
 
Hi all -


When I create a custom OCaml toplevel, a message prints out:

  Objective Caml version 3.09.3

Is there any way to suppress this?  I'd like to replace it with my own
message.

Thanks!

Andrew

#8609 From: Fabrice Marchant <fabrice.marchant@...>
Date: Wed Sep 5, 2007 8:57 pm
Subject: Re: "ocaml_beginners"::[] Re: Unable to fold this
fabrice.marc...
Send Email Send Email
 
On Wed, 05 Sep 2007 13:27:27 +0200
Zheng Li <li@...> wrote:

Thanks Zheng for your rich answer :
   the code, the detailed explanations about computation costs and the very
valuable link to your survey
http://caml.inria.fr/pub/ml-archives/caml-list/2007/03/44de9b27bfaf73265501dafcf\
be6b78c.en.html
  that refers to Erik de Castro Lopo question
http://caml.inria.fr/pub/ml-archives/caml-list/2007/02/cf0ae15f6f6e18ebf71c79c12\
7d41a74.en.html
We asked about the same nested loops !
A lot of interesting answers there.

   Hacking Christophe Troestler "foreach_elt" code - in this topic -, I was able
to solve my second problem of "multi-permutations" (needed for experimentations
about graph isomorphism).
   Working on a Set of Integer sets couple, it differs a bit from your
multi-permuter on a list of intervals :
http://fabrice.marchant.free.fr/OCamlCode/multiPerm.ml.html

   It is yet possible to use a step by step iterator in order to do combinations
:
* like here for a set :
http://tech.groups.yahoo.com/group/ocaml_beginners/message/8240

* We can generate permutations one-by-one too :
http://fabrice.marchant.free.fr/OCamlCode/stepPermuter.ml.html
This would allow, in a same way to combine several permutations.

Regards,

Fabrice

#8610 From: Johann Spies <jspies@...>
Date: Fri Sep 7, 2007 8:35 am
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
jspies@...
Send Email Send Email
 
On Thu, Sep 06, 2007 at 12:54:14PM +0100, Richard Jones wrote:
> On Thu, Sep 06, 2007 at 11:39:18AM +0200, Johann Spies wrote:
> > On Thu, Sep 06, 2007 at 10:11:57AM +0100, Richard Jones wrote:
> > > On Wed, Sep 05, 2007 at 03:42:26PM +0200, Johann Spies wrote:
> > > > [pid 29893] read(4, "E\0\0\0\\SFATAAL\0C28000\0Mpassword au"..., 4096)
> > >
> > > That's the error ... If you run strace with the `-s' option you'll be
> > > able to see more of it.
> > >
> > Thanks. I am learning...
> >
> > But: I can use psql with the same environmental variables ( psql -h
> > $PGHOST -d $PGDATABASE -U $PGUSER -p $PGPORT --password) and log in
> > with the same password. Why not using pgocaml?
>
> I've no idea, but I guess the error message will tell you.

Thanks for your trouble.  My preference was to use your library, but I
have wasted several hours now to get it working.  I do not understand
the logic behind the fact that the connection must be made at
compile-time and do not understand how it can then be possible to
build something that will work on another system.

It is also not clear to me whether your library is using ssl when
connecting over the network - as is the case with psql.

I could at one stage get a test program (from the pdf-documentation
recently published on this list) to compile and connect to
localhost.

But I could not repeat it the following day and I cannot see why.

I can work with the debian library (libpostgresql-ocaml) without these
problems.  I can connect and manipulate databases on localhost and
other databases on the network.


Regards
Johann

--
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

      "For whosoever shall call upon the name of the Lord
       shall be saved."         Romans 10:13

#8611 From: "Jake Donham" <jake@...>
Date: Fri Sep 7, 2007 4:24 pm
Subject: array comparison
Jake_Donham
Send Email Send Email
 
Hi,

I came across a little mystery about comparing arrays of different length:

  # compare [ 1; 2 ] [ 2 ];;
  - : int = -1
  # compare "12" "2";;
  - : int = -1
  # compare [| 1; 2 |] [| 2 |];;
  - : int = 1

I would have thought that these pairs of values would all compare the
same. Is there a good reason for this? Thanks,

Jake

#8612 From: "darioteixeira" <darioteixeira@...>
Date: Fri Sep 7, 2007 5:48 pm
Subject: Thread-safety of OCaml libraries
darioteixeira
Send Email Send Email
 
Hi,

I have a doubt about the general status of thread-safety among OCaml
libraries.  Some libraries will explicitly state whether or not they can
be used concurrently, but others do not.  Is the stdlib thread-safe, for
example?  What about other notable libraries, such as ExtLib or Ocamlnet?
I expect that at least the fully functional parts ought to be, but I
would like to be sure.

I appreciate your help,
Dario

#8613 From: "darioteixeira" <darioteixeira@...>
Date: Fri Sep 7, 2007 5:58 pm
Subject: Re: "ocaml_beginners"::[] pgocaml: how to use it?
darioteixeira
Send Email Send Email
 
Hi,

> Thanks for your trouble.  My preference was to use your library,

Well, don't give up so easily.  We're here to help...


> have wasted several hours now to get it working.  I do not understand
> the logic behind the fact that the connection must be made at
> compile-time and do not understand how it can then be possible to
> build something that will work on another system.

The logic is simple: if the database we not known at compile-time,
how could PG'OCaml possibly know about the database types?

This at first sight seems like a huge limitation, but if you
think about it, it does not restrict the use of the same programme
on different systems.  Note that the function PGOCaml.connect
allows you to specify the connection parameters to be used at
runtime.  You can therefore use environment variables and/or
statement flags to specify compile-time parameters, and use
environment variables and/or PGOCaml.connect arguments for
runtime parameters.

> But I could not repeat it the following day and I cannot see why.

You can always build a very minimal example that replicates your
problem and post it on this list.

Cheers,
Dario

#8614 From: "Grant Olson" <olsongt@...>
Date: Sat Sep 8, 2007 10:57 pm
Subject: Anyone know of some good sample code using the Arg module?
olsongt@...
Send Email Send Email
 
I'm not finding the documentation in the manual for the 'Arg' module to be
very intuitive.  I suppose I could spend an hour or two experimenting, but
if anyone could point me to some sample code that is already using the arg
module I'd appreciate it greatly.

-Grant

#8615 From: Fabrice Marchant <fabrice.marchant@...>
Date: Sat Sep 8, 2007 10:40 pm
Subject: Re: "ocaml_beginners"::[] Anyone know of some good sample code using the Arg module?
fabrice.marc...
Send Email Send Email
 
#8616 From: Andre Kuehne <andre.kuehne@...>
Date: Sun Sep 9, 2007 11:10 am
Subject: accessing record fields from other modules without open
andrekuehne
Send Email Send Email
 
Hello

Compiling this code:

     ...
     let status = Graphics.wait_next_event [Graphics.Poll] in
     if status.button or status.keypressed then exit 0;
     ...

I get the following error:

     Unbound record field label button

I get no error if i put a

     open Graphics

at the top of the file, but how can i access the record field without opening
Graphics?

Regards
Andre

#8617 From: Vincent Aravantinos <vincent.aravantinos@...>
Date: Sun Sep 9, 2007 11:26 am
Subject: Re: "ocaml_beginners"::[] accessing record fields from other modules without open
vincent.arav...
Send Email Send Email
 
Le 9 sept. 07 à 13:10, Andre Kuehne a écrit :

> Hello
>
> Compiling this code:
>
>     ...
>     let status = Graphics.wait_next_event [Graphics.Poll] in
>     if status.button or status.keypressed then exit 0;
>     ...
>
> I get the following error:
>
>     Unbound record field label button
>
> I get no error if i put a
>
>     open Graphics
>
> at the top of the file, but how can i access the record field
> without opening Graphics?

What about :

status.Graphics.button

?

#8618 From: Andre Kuehne <andre.kuehne@...>
Date: Sun Sep 9, 2007 12:41 pm
Subject: camlimages: save Graphics buffer as PNG
andrekuehne
Send Email Send Email
 
Hello

I want to save the current Graphics buffer as a PNG-Image.

With this code:

     let img = Graphic_image.get_image 0 0 width height in
     Images.save "image.png" None [] img;

I get the following error:

     This expression has type Rgb24.t but is here used with type Images.t

But if i look at images.mli:

type t =
    | Index8 of Index8.t
    | Rgb24 of Rgb24.t
    | Index16 of Index16.t
    | Rgba32 of Rgba32.t
    | Cmyk32 of Cmyk32.t;;

Doesn't this mean that Rgb24.t is a subtype of Images.t and thus should be
compatible?

Can someone show me how to do this right?

Regards
Andre

#8619 From: "andrekuehne" <andre.kuehne@...>
Date: Sun Sep 9, 2007 1:10 pm
Subject: Re: "ocaml_beginners"::[] accessing record fields from other modules without ope
andrekuehne
Send Email Send Email
 
--- In ocaml_beginners@yahoogroups.com, Vincent Aravantinos
<vincent.aravantinos@...> wrote:
>
>
> Le 9 sept. 07 à 13:10, Andre Kuehne a écrit :
>
> > Hello
> >
> > Compiling this code:
> >
> >     ...
> >     let status = Graphics.wait_next_event [Graphics.Poll] in
> >     if status.button or status.keypressed then exit 0;
> >     ...
> >
> > I get the following error:
> >
> >     Unbound record field label button
> >
> > I get no error if i put a
> >
> >     open Graphics
> >
> > at the top of the file, but how can i access the record field
> > without opening Graphics?
>
> What about :
>
> status.Graphics.button
>
> ?
>

Yes this works.

Thanks
Andre

Messages 8590 - 8619 of 13890   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help