<thelema>
I can write a version that inserts efficiently, but it's much more complex.
<thelema>
I guess you could reorganize it into a String.iteri function and the action to do at each location.
<thelema>
palomer: but other than hoisting the (String.length to_insert) out of the loop, and writing str.[i] instead of String.get str i
<thelema>
also, "else ()" can be elided in ocaml.
<palomer>
hrmph
<palomer>
I don't care about efficiency
<thelema>
do you care about the difference between blitting and inserting?
<palomer>
to tell you the truth
<palomer>
I don't know what blitting means
<palomer>
String.blit src srcoff dst dstoff len copies len characters from string src, starting at character number srcoff, to string dst, starting at character number dstoff. It works correctly even if src and dst are the same string, and the source and destination chunks overlap. Raise Invalid_argument if srcoff and len do not designate a valid substring of src, or if dstoff and len do not designate a valid substring of dst.
<palomer>
I'm guessing that it doesn't change the length of the string
<thelema>
exactly. it overwrites a slice of the string.
<palomer>
looking at the String module
<palomer>
there best way is to take the substring on either side
<palomer>
and then use ^
<palomer>
what's iteri?
<palomer>
can't find it in the module
<thelema>
it doesn't exist in String, only Array
<palomer>
a string is an array?
coucou747 has joined #ocaml
<thelema>
no, they're different.
<palomer>
oh
<thelema>
but almost the same code would implement String.iteri
<thelema>
Arrays always have 32/64-bit entries. Strings always have 8-bit entries.
<thelema>
err, arrays are word-indexed, strings are byte indexed.
<thelema>
nsplit still needs to be called String.nsplit
<thelema>
even after you [open ExtString]
<palomer>
ahh
<palomer>
got it
<coucou747>
@+
coucou747 has quit ["bye ca veut dire tchao en anglais"]
mwc has left #ocaml []
evn_ has quit []
ttamttam has joined #ocaml
l_a_m has joined #ocaml
thermoplyae has quit ["more homotopy tomorrow"]
Demitar has quit [Remote closed the connection]
Demitar has joined #ocaml
Snark has joined #ocaml
aminore1 has quit [Read error: 104 (Connection reset by peer)]
m3ga has joined #ocaml
schme has joined #ocaml
yangsx has quit [Read error: 110 (Connection timed out)]
hkBst has joined #ocaml
goalieca has quit [Remote closed the connection]
jlouis has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has joined #ocaml
jlouis_ has joined #ocaml
gene9 has joined #ocaml
<gene9>
Is it possible to use types declared in modules in external functions. I tried to explain what I need here: http://pastebin.com/mbd5a858
jlouis has quit [Read error: 110 (Connection timed out)]
<jlouis_>
gene9: your problem is that t is abstract outside the module.
<jlouis_>
suppose I came up with module Y : Z = struct type t = int end;;. Then my code should work equally well when evaluating fn(10.2) which it obviously doesn't
<Anarchos>
or look at the introductory section of the official manual
<Smerdyakov>
Anarchos, the manual has nothing that deserves to be called "a semantics."
<Yoric[DT]>
Mmmhhh....
<Yoric[DT]>
Translation to lambda-calculus is probably not what I want.
<Yoric[DT]>
Well, I'll pick what I can from u3-ocaml.
<Yoric[DT]>
Thanks.
<Smerdyakov>
Translation to lambda calculus is the most practical way of giving semantics to functional languages.
<Yoric[DT]>
Sure.
<Yoric[DT]>
It just happens so that I haven't taught lambda-calculus yet to my students.
<Yoric[DT]>
I don't have nearly enough hours to teach them both OCaml, Logics, Algorithmics Complexity *and* Lambda-Calculus.
<Anarchos>
Yoric[DT] so you'd better teach complexity in pascal ;)
<Yoric[DT]>
:)
<Yoric[DT]>
Worse than that, I'm expected to teach Complexity in both OCaml and Java.
<Yoric[DT]>
So I can't rely on lambda-calculus alone.
<Anarchos>
Yoric[DT] how many semesters have you ??
<jlouis_>
If he says .5, I cringe
<Yoric[DT]>
They've had 3 terms of Java (as their only course of computer science).
<Yoric[DT]>
Now, they've 1 term of OCaml and Logics + Complexity.
<Yoric[DT]>
The half-term on Logics is complete.
<Yoric[DT]>
They know enough OCaml to program some decent stuff (they've already programmed a Game of Life using OCamlSDL).
<Yoric[DT]>
And tomorrow starts the half-term on Complexity.
<Yoric[DT]>
To the best of my knowledge, algorithmic complexity doesn't have much in the way of theory (by opposition to computational complexity, which I just can't teach in .5 term), so I intend to complete this by an informal introduction to semantics.
RobertFischer has joined #ocaml
nuncanada has quit [Remote closed the connection]
postalchris has quit [Read error: 110 (Connection timed out)]
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
rogo has joined #ocaml
delamarche has joined #ocaml
mikeX has joined #ocaml
<mikeX>
hello, does the ML standard enforce tail call optimization?
<Smerdyakov>
What does this have to do with OCaml?
<Smerdyakov>
OCaml is governed by no standard and doesn't even have a real language definition.
<mikeX>
well it doesn't really, I just thought someone here would know this :)
<Smerdyakov>
So you're asking about the Definition of Standard ML?
<mikeX>
as I said, I just thought someone here would know this :)
<mikeX>
you for example
<Smerdyakov>
I asked a question, and I can't help you if you don't answer it.
<mikeX>
I did answer it, because I thought someone here might know about the Definition of SML
<mikeX>
nothing to do with ocaml
<mikeX>
(some actually, my next question would be O'Caml's approach to tail call optimization)
<Smerdyakov>
You didn't answer my question.
<Smerdyakov>
It seems you're implying now that your answer is "yes."
<mikeX>
hmm, what was your question then?
<Smerdyakov>
<Smerdyakov> So you're asking about the Definition of Standard ML?
<mikeX>
well, from a conversational view point
<mikeX>
oh, I missed the ? on that line. Yes I am
<mikeX>
sorry
<Smerdyakov>
I don't think the Definition says anything about implementation. It only specifies semantics.
<mikeX>
What about the mlton implementation then
<Smerdyakov>
Every real functional language implementation does tail call optimization.
<thelema>
TCO helps so much in functional languages that implementors don't forget it.
<mikeX>
what about trying to convert non tail-recursive calls to tail-recursive
<Smerdyakov>
Hardly any do that.
<Smerdyakov>
I couldn't name off the top of my head an implementation that does.
<mikeX>
I see, I thought mlton might give that a go
<mikeX>
or maybe stalin
<thelema>
managing side effects of reordering code... difficult. haskell or another extremely pure language might.
<Smerdyakov>
Haskell doesn't count as "extremely pure" in my book.
<Smerdyakov>
What does "extremely" add over "pure" that you think Haskell has?
<thelema>
you're right, I should have just said "pure"
<jlouis_>
mikeX: Hardly any implementations do that. And it is not worth the effort. As soon as the profiler has targeted your space-cost-centre, you rewrite it to tail-call form and then the problem is out of the way.
<jlouis_>
mikeX: That said, The only implementation of Standard ML which may avoid TCO is Hamlet. Hamlet seeks to in isomorphism with the Definition of SML.
<jlouis_>
to be in..
<mikeX>
i see, thanks jlouis_
<thelema>
neale: I like my version: split the string and use String.concat (which is quite efficient) to join the substrings with the right separator.
Linktim has joined #ocaml
postalchris has joined #ocaml
<thelema>
the only way to make it more efficient would be to use (pos,len) pairs for intermediate values (location of what to keep), and then piece the new string together with only one string copy per segment
<thelema>
l
ttamttam has left #ocaml []
Amorphous has quit [Connection timed out]
<neale>
thelema: oh, yeah, that's good too
<neale>
(String.concat)
ikaros has quit ["segfault"]
evn_ has joined #ocaml
evn_ has quit [Read error: 104 (Connection reset by peer)]
evn_ has joined #ocaml
marmottine has joined #ocaml
yminsky_ has joined #ocaml
yminsky has quit [Read error: 104 (Connection reset by peer)]
prince has quit [Nick collision from services.]
prince has joined #ocaml
marmottine has quit [Remote closed the connection]
postalchris has quit [Read error: 110 (Connection timed out)]
marmottine has joined #ocaml
johnnowak has quit []
ita has joined #ocaml
bluestorm has joined #ocaml
ygrek has joined #ocaml
thermoplyae has joined #ocaml
munga has quit ["Leaving"]
evn_ has quit []
jlouis has joined #ocaml
ttamttam has joined #ocaml
postalchris has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
thermoplyae has quit ["daddy's in space"]
ttamttam has left #ocaml []
Linktim has quit [Remote closed the connection]
szell` has joined #ocaml
psnively has quit []
psnively has joined #ocaml
szell has quit [Connection timed out]
bluestorm is now known as bluestorm_aw
rogo has left #ocaml []
gim_ has quit [Read error: 110 (Connection timed out)]
ppsmimram has quit [Read error: 110 (Connection timed out)]
bluestorm_aw is now known as bluestorm
l_a_m has quit [Remote closed the connection]
Anarchos has joined #ocaml
ygrek has quit [Remote closed the connection]
thermoplyae has joined #ocaml
dibblego has quit [Remote closed the connection]
thermoplyae has quit [Read error: 110 (Connection timed out)]
bluestorm has quit ["Konversation terminated!"]
Demitar has joined #ocaml
ita has quit ["Hasta luego!"]
jlouis_ has joined #ocaml
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
marmottine has quit [Remote closed the connection]
Yoric[DT] has quit ["Ex-Chat"]
jlouis__ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]