Hi ... Yes, I agree that there are some type related problems in that. At least, there obviously should be some special pattern type that could handle every...
Hi Thanks for your very clear answer. I think you are right. To conclude a bit: 1) The reason why we can't manage to do this is that pattern is not first class...
Hi, thanks ... Although not a universal solution, this is quite an interesting hack working for some purposes. It does help in a way that the user writes and...
Hi, thanks I'm not sure I've caught your meaning totally (I'm oriental :) ), but thanks for the long post. I will try to answer as I can. ... Yes, partly...
pattern matching can be implemented using recursive descent parsing, which is described in cousineau and mauny (using ocaml!). the idea is that you want to...
andrew cooke
andrew@...
Jan 1, 2005 8:18 pm
2871
I'm a little unsure whats the best way to try and find 2 elements in a list that are next to each other. For example if I had a list [1;2;3;4;5] and I wanted...
... I'm fairly certain that the standard library doesn't contain any functions for considering adjacent elements. But it's easy enough to write your own! The...
... I don't know if this is the "best way", but I guess it's not very bad either ocaml # let rec find_next l a b = match l with ... ;; val find_next : 'a list...
... It's correct but weird, why use List.tl when you are doing a pattern matching ? a better version would be: # let rec find_next l a b = match l with ... It...
... you are right that was the one I ended up with after cleaning my previous version, so I agree with you. Would you care to try to solve my other problem. ...
how about: let sublist a b = let rec shared a b = match (a, b) with (_, []) -> true ... let rec step a = match a with [] -> false ... and sublist'...
andrew cooke
andrew@...
Jan 7, 2005 5:44 pm
2879
... This is probaby the easier way to do this, but it is not the more efficient one. In fact it is an intersting problem, and probably the same as the search...
Hi, If what you mean is advanced string matching algorithm like KMP in OCaml, I don't have idea either. As the simple algorithm, I think my solution is just...
[repost- original never showed up] ... When the function is corrected, this gives: val test_pairs : ('a -> 'a -> bool) -> 'a list -> bool = <fun> Rich....
... don't they assume constant time access to characters (arrays)? this question is about linked lists. andrew -- ` __ _ __ ___ ___| |_____ work web site:...
andrew cooke
andrew@...
Jan 7, 2005 7:04 pm
2883
... At first sight KMP doesn't seem to be easily adapted to linked lists, as you said. But I'm pretty sure it can be done for Rabin-Karp. I'll have to try...
On Fri, 7 Jan 2005 16:04:22 -0300 (CLST), andrew cooke ... Well, I haven't reread the KMP algorithm recently, but I remember that the idea is more or less to...
ok, maybe i'm confusing my substring algorithms. i thought the important part of the "standard fast solution" (maybe i'm even wrong in thinking there is such...
andrew cooke
andrew@...
Jan 7, 2005 8:53 pm
2886
On Fri, 7 Jan 2005 17:53:09 -0300 (CLST), andrew cooke ... KMP jump ahead in string we are looking for, not in the string we are looking into. And one can see...
Or you could copy the sublist into an array first, then you can use integer offsets on the sublist. Seems easier than storing references to sublists......
... Sure. By the way I've tried to do what I meant, and the result can be find at teh follwoing url: http://aspellfr.free.fr/ocaml_things/. I've done two...
... List walking and pattern matching will do it. You can match on multiple elements of the list simultaneously. Code like this should work: let rec...
... No surprises. Here is the code (not cleaned up, sorry): ===== exception No_match;; let rec pow_mod a b q = if b = 1 then a mod q else if b > 1 then (a *...
thanks for the clarification - i obviously need to go back and look at this again. i'll have a look, but it will be in a few weeks i'm afraid, as i'm now away...
andrew cooke
andrew@...
Jan 9, 2005 9:13 pm
2892
Hi, Has anyone come across the error "contains type variables which cannot be generalized"? If I try to compile the attached file (foo.ml, it 120 lines, too...
... Yes, that happens sometimes. This is because the compiler needs to know the type of something but it doesn't know it at the point it needs it. For instance...
How can i avoid the name conflicts of modules in different lib? For example, in lib canlendar there is a module called Printer. But i have another Printer...
... Unfortunately the answer is "with difficulty". If you have source to the libraries, you could change the name of one or other of the modules. It may also...