<ocaml615>
let rec insertletters l length word = match word with | word -> insert l length; insertletters l (length + 1) (String.sub word (length + 1) (String.length word - 1)); in insertletters [] 0;
<ocaml615>
Question about the code.
<ocaml615>
I am not getting how to return the list returned by "insert l length" at the end of the recursion.
<Leonidas>
ocaml615: why are you matching word with word?
<Leonidas>
that does… nothing?
<ocaml615>
Ok. I've tried using "function" by removing the match clause.
sepp2k has joined #ocaml
<ocaml615>
The list returned by insert l length; should be the return type. I don't know how to return it finally at the end of the recursion.
<ocaml615>
let rec insertletters l length = function | word -> insert l length; insertletters l (length + 1) (String.sub word (length + 1) (String.length word - 1)); in insertletters [] 0;
<ocaml615>
This function is inside another one with parameter "word"
<lyxia>
ocaml615: Is l a list, or is it a reference to a list? What is the type of insert?
<Leonidas>
ocaml615: let foo = insert l length in insertletters …; foo to return the value
<Leonidas>
ocaml615: but overall it kinda looks… wrong what you're doing. you shouldn't need ; at all
wu_ng has quit [Remote host closed the connection]
<Leonidas>
ocaml615: what is the function supposed to do?
AlexRussia has quit [Ping timeout: 246 seconds]
<ocaml615>
"mnn" [('m',1),('n',2)]
<ocaml615>
Let me the new let syntax .
<Leonidas>
Algebr: heh :)
<ocaml615>
I am new to OCaml. Java background :-)
<Leonidas>
ocaml615: btw, the point still stands, if you `match word with | word ->` that's just like saying `word`.
jwatzman|work has joined #ocaml
<Leonidas>
like `if word then word else word`
<Leonidas>
1) figure out what you're recursing over
<Leonidas>
2) figure out when the recursion stops
<Leonidas>
3) figure out what the return value is in that case
<Leonidas>
4) write the code
<ocaml615>
How do I iterate over a string and process each char without using imperative code ?
<ocaml615>
Should I use String.get ?
<lyxia>
Is not using imperative code really your objective
<vramana>
ocaml615: First split the string into a list and use List.map
ygrek has quit [Ping timeout: 250 seconds]
<lyxia>
String.iter "iter"ates over a string.
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Algebr>
hmm, melpa release of tuareg mode broke tuareg mode, get (error "Too many arguments")
<Algebr>
the joys of elisp.
<ocaml615>
String.iter ( fun x -> insert l x;() ) word I couldn't return the final list from insert back from this function.
<ocaml615>
let syntax ?
AlexDenisov has joined #ocaml
<lyxia>
insert does not do any mutation
<lyxia>
I guess, since you didn't tell us how it's defined
<lyxia>
if you use iter, you need a reference to mutate
<ocaml615>
let f = insert in String.iter ( fun x -> f l x;() ) word
<ocaml615>
insert mutates
<ocaml615>
f refers to a function. Not the mutated list :-)
<lyxia>
what is the type of insert
<ocaml615>
list -> char -> list
<lyxia>
Now I doubt that mutates anything.
<lyxia>
ocaml615: Can you show the definition of insert
<ocaml615>
It does. It creates tuples in the list. [('a',1); ('b',3)]
<Drup>
ocaml615: No. It returns a *new* list with additional elements
<ocaml615>
Yes. Understand. No mutation. Java background :-)
<def`>
so it is ok if Lwt.return_unit == Lwt.return_false
<def`>
And you remember well, I did work for adding backtraces to lwt, but it requires a specific version of Lwt, I wonder if people would be interested.
<flux>
..are you kidding, "if people would be interested" :-), though personally I make very little use of Lwt.
<flux>
I'm guessing though Ocsigen folks would be VERY happy with such a thing.
Algebr has quit [Ping timeout: 250 seconds]
<aantron>
ocsigen folks aside, i would be happy with such a thing
<aantron>
if you have a good improvement to backtraces in mind, i definitely want it in lwt, and will aid getting it in
<companion_cube>
is there, per chance, a *very* fast hashconsing library somewhere?
<companion_cube>
(possibly with C inside)
<aantron>
def` ^
<Drup>
companion_cube: david monnaixu's one ?
<Drup>
monniaux*
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
infinity0 has quit [Remote host closed the connection]
<Drup>
aantron: wrap already means "wrapping exceptions into Lwt.t", so it's a bit redundant
jao has quit [Ping timeout: 250 seconds]
infinity0 has joined #ocaml
<aantron>
well Lwt.wrap does a bit more than that, it wraps both values and exceptions..
chris2 has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
Algebr has joined #ocaml
jao has joined #ocaml
cheater has quit [Ping timeout: 240 seconds]
slash^ has joined #ocaml
<hannes>
hmm, ocamlbuild questio: is having in _tags a <foo>: -traverse supposed to have the same effect as using an argument on ocamlbuild invocation -tag-line "<foo>: -traverse"? I thought it would be the same, but it doesn't look like it does :/
<hannes>
s/does/is/
maattdd has quit [Ping timeout: 268 seconds]
octachron has joined #ocaml
<adrien>
I thought it did
<aantron>
hrm. is it possible to expand environment variables in commands executed by opam?
jao has quit [Remote host closed the connection]
jao has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
cheater has joined #ocaml
govg has joined #ocaml
cheater has quit [Ping timeout: 260 seconds]
_andre has quit [Quit: leaving]
zpe has joined #ocaml
kakadu has joined #ocaml
freusque has joined #ocaml
AlexDenisov has joined #ocaml
cheater has joined #ocaml
ygrek has joined #ocaml
planet_en has joined #ocaml
planet_en has quit [Client Quit]
freusque has quit [Ping timeout: 260 seconds]
cheater has quit [Ping timeout: 265 seconds]
cheater has joined #ocaml
AlexDeni_ has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
jnavila has joined #ocaml
planet_en has joined #ocaml
cheater has quit [Ping timeout: 245 seconds]
planet_en has quit [Ping timeout: 245 seconds]
isd has quit [Ping timeout: 265 seconds]
cheater has joined #ocaml
isd has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
orbifx has joined #ocaml
yomimono has joined #ocaml
jnavila_ has joined #ocaml
dhil has quit [Ping timeout: 248 seconds]
jnavila has quit [Ping timeout: 256 seconds]
larhat has joined #ocaml
cheater has quit [Ping timeout: 248 seconds]
cheater has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
nomicflux has quit [Quit: nomicflux]
sepp2k has quit [Quit: Leaving.]
johnf_ has quit [Remote host closed the connection]
namosca has joined #ocaml
<namosca>
hi all
freusque has joined #ocaml
nomicflux has joined #ocaml
<zozozo>
hi
zirman has quit [Remote host closed the connection]
Sim_n has joined #ocaml
zirman has joined #ocaml
Simn has quit [Ping timeout: 250 seconds]
zirman has quit [Remote host closed the connection]
zirman has joined #ocaml
octachron has quit [Quit: Leaving]
rand__ has quit [Quit: leaving]
<namosca>
hey zozozo, I am quite new to Ocaml and I have looked on how to use GLFW with OpenGL, but I just found old stuff
zirman has quit [Remote host closed the connection]
<zozozo>
:o
<namosca>
zozozo, are you aware of something well supported for working with opengl in ocaml?
<orbifx>
yet it complains it can't find this module when I try to build it
<orbifx>
any ideas?
<orbifx>
(when I try to build something using it)
<def`>
namosca: I think it's ok if you want to stay with glfw
<def`>
but I can only confirm that tsdl2 works well :)
<namosca>
def`, do you use it frequently?
<def`>
h
zirman has joined #ocaml
zirman has joined #ocaml
zirman has quit [Changing host]
orbifx1 has joined #ocaml
<namosca>
def`, h means yes or no? :D
<def`>
hmm, I played with it
<def`>
however I never did anything serious :)
zirman has quit [Remote host closed the connection]
zirman has joined #ocaml
zirman has joined #ocaml
zirman has quit [Changing host]
<namosca>
def`, I am playing too... :D BUt have you at least got some image on the screen?
marsam has quit [Read error: Connection reset by peer]
tane has quit [Quit: Leaving]
AlexDeni_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<orbifx>
namosca: http://erratique.ch libraries worked for opengl when I tried the example
<namosca>
orbifx, I installed via OPAM the tsdl and tgls... i am learning Ocaml since one day only so it will take some days until I can really test it... i am still on page 50 of "Ocaml from the very beginning" :D
<orbifx>
k, yeah you have some way to go
zirmann has joined #ocaml
zirmann has quit [Remote host closed the connection]
zirman has quit [Ping timeout: 265 seconds]
zirman has joined #ocaml
zirman has joined #ocaml
zirman has quit [Changing host]
zirmann has joined #ocaml
yegods has quit [Remote host closed the connection]
nomicflux has quit [Quit: nomicflux]
zirman has quit [Ping timeout: 248 seconds]
namosca has quit [Quit: Leaving]
<orbifx>
problem resolved
Sorella has joined #ocaml
yegods has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
yegods has joined #ocaml
<rgrinberg>
Is there a way to set a cap on the heap size in OCaml?
<companion_cube>
you can play with the Gc params, but I don;'t think you can have a hard limit
<companion_cube>
(what would happen? an exception?)
<rgrinberg>
companion_cube: Sure. Or a Gc pause :P
zirman has joined #ocaml
zirman has joined #ocaml
zirman has quit [Changing host]
Muzer has quit [Read error: Connection reset by peer]
erblite has joined #ocaml
kakadu has quit [Remote host closed the connection]
zirmann has quit [Ping timeout: 260 seconds]
zirman has quit [Ping timeout: 260 seconds]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
rgrinberg has quit [Remote host closed the connection]
Sim_n has quit [Quit: Leaving]
yomimono has quit [Ping timeout: 252 seconds]
Muzer has joined #ocaml
<Algebr>
couldn't you do that at the OS level
yegods has quit [Remote host closed the connection]
<companion_cube>
probably with systemd
FreeBirdLjj has quit [Remote host closed the connection]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
erblite has quit [Quit: WeeChat 1.5]
zpe has quit [Ping timeout: 268 seconds]
yegods has joined #ocaml
nomicflux has joined #ocaml
<Armael>
companion_cube: I can't tell if you're trolling
<cheater>
no i meant the syntax that goes "module type ..."
<cheater>
like module type PLUS = ... near the end of 4.1.1
<cheater>
is that the same as polymorphism in haskell?
<cheater>
same/similar
<Drup>
the equivalent of the bit of haskell you posted is "type 'a foo = Bar of 'a"
<Drup>
I'm not sure what's your syntax question, module types are not directly related to polymorphic types
<cheater>
ok look in 4.1.1 where they define module type CURRENCY
<cheater>
and compare it to module Float
zirman has joined #ocaml
<cheater>
that looks to me like polymorphism in the same way as you'd compare something like... data MyFloat = MyFloat Float vs data Currency a = Currency a
<cheater>
in haskell
<Drup>
Not really no
isd1 has joined #ocaml
<cheater>
why not? what's the difference?
<Drup>
first off, in your analogy, Float would be a value, and CURRENCY is the type
<Drup>
not two types
isd has quit [Disconnected by services]
<cheater>
sorry wait
isd1 is now known as isd
<cheater>
you mean in the OCaml example, where it says module Float = ..., Float is a value?
<Drup>
Yeha, it is, but that's not the important bit
<cheater>
go on
<Drup>
the same as 3 as type int, module Float as a type (which is compatible with CURRENCY)
<Drup>
has*
zirman has quit [Ping timeout: 268 seconds]
<Drup>
your comparison with polymorphic types is incorrect: MyFloat is not a compatible type with Currency, and modules are not just types, they are a thing that contains several declarations (types, values, other modules)
<cheater>
sure, modules contain values and other modules, i was just focusing on the types
<cheater>
but i see what you mean now about value vs type
<Drup>
The fact that Float is compatible with CURRENCY is just structural typing. You can always make a type abstract in the signature, since it exposes strictly less information.
<cheater>
sorry, i don't understand those two statements. what is structural typing in the way you use it here and how does the compatibility follow from that? what does it mean to make a type abstract in the signature? what does it mean it exposes less information?