<pattern>
the way i read it, it asks for a function that takes a list of elements and produces a list of functions, which each function in the list being the application of a function in the original function list to the corresponding element in the list of elements
<pattern>
i've been able to produce a list of elements of each function in the function list being applied to each element in the list of elements
<pattern>
but not a list of functions of the same
<pattern>
by the way, in the original problem description, the (i) in f(i) is actually a subscript of f, without the parenthesis
<pattern>
and same for the (i) in F(d(i))
<pattern>
by using the i subscript i assume they mean the i'th element of the list of functions and the corresponding i'th element of the list of d elements
<Nutssh>
Suggestion. Write out the types of the inputs and outputs, use 'a 'b 'c 'd for abstract types.
<pattern>
but the thing is i don't understand what the output should be
<pattern>
i don't understand what the problem is asking for
<Nutssh>
Puzzle out the types. When you have the types, writing the code should be straightfoward.
<pattern>
how can you have a list of functions of the type they seem to ask for?
<Nutssh>
('a -> 'b) list is the type of a list of functions.
<pattern>
i don't know what types they're asking for
<pattern>
but that doesn't seem to be what they ask for
<pattern>
they do say "a list of functions"
<pattern>
however
<pattern>
each function is supposed to be a function from the original list applied to the corresponding element in the list of elmenets
<pattern>
so what is the input to the function in each function in the resulting function list?
<pattern>
it makes no sense
reltuk has quit ["leaving"]
<pattern>
it has to be either a list of functions or a list of elements of the original function applied to the corresponding element in the element list, not both
<Nutssh>
Write each thing they discuss as a type. And link things together with type equations if f: 'a -> 'b and 'b = 'c list, then f: 'a -> 'c list
<pattern>
ok, i'll try
<pattern>
but, nutssh, do you think my solution is correct?
<pattern>
because each of those functions in the list should take an argument (presumably the element from the list of elements they're to be applied to), but how are they then applied to the corresponding element in the list?
<pattern>
kinners, what do you mean?
<pattern>
maybe the functions in the resulting list of functions are supposed to take a unit argument
<pattern>
that would make a bit more sense, except that the problem mentions nothing about that
<Kinners>
pattern: is the 'b in F ('T1 -> 'T2) ?
<Kinners>
pattern: like (pseudo-code) type F = 'D -> ('T1 -> 'T2)
<pattern>
i don't think so
<pattern>
i guess it could be, as F performs some transformation on each d
<pattern>
and i guess there's no reason why the result of that transformation couldn't be a function
<pattern>
hmmm
<pattern>
oh, wait, you're right
<pattern>
i just ignored the whole 'T1 -> 'T2 part of the first part of that problem
<pattern>
duh
<pattern>
ok... so now i have to think about this again
<pattern>
thanks, kinners
<pattern>
ok, definitely making much more sense now
mw is now known as windows
windows is now known as mw
<Kinners>
pattern: you can even get ocaml to do type checking for ya :) such as let foo (f:'D->('T1->'T2) as 'R) = ... let (g:'D list -> 'R list) or something like that
<pattern>
i think i did solve it now, just by changing "let f = fun x -> x +. 1.0 in" to "let f = fun x -> ( +. ) x in"
<pattern>
super neat, kinners!!!
<pattern>
now, when you say "as 'R" in the type specification that means that 'R is the return type of foo?
<Kinners>
pattern: it just becomes an alias for 'T1 -> 'T2
<pattern>
oh, right
<pattern>
hmm
<pattern>
that's kind of what i thought... i just never saw "as" used in a type specification, just in a pattern match
<pattern>
here's a related problem i'm running in to... i was trying to make some use of that resulting list of functions in the previous problem by creating a function that takes a list of functions and applies each function in the list to an element in another list:
<pattern>
but ocaml tells me that that is: val applylist : ('a list -> 'a list) list * 'a list list -> 'a list list =
<pattern>
<fun>
<pattern>
instead of what i want (or think i want), which is an ( ('a -> 'a) * 'a ) list )
<pattern>
but i don't see where i'm going wrong
<pattern>
scratch that last parenthesis in my last type statement above
<pattern>
oh, wait, that's not the type that i want
<Kinners>
yeah, I was just about to say :)
<pattern>
i want: ('a -> 'a) list * 'a list
<pattern>
i think
<pattern>
which is still not what the function i wrote is
<Nutssh>
How about a helper function: ('a -> 'a) list -> ('a -> 'a)
<Nutssh>
Should be a one-liner with List.fold*
<pattern>
hmm
<pattern>
so you're saying there should be a helper function which takes a list of functions and returns a function?
<pattern>
why?
<Kinners>
if the lists are the same length then there are the List.*2 functions for operating over two lists
<pattern>
i thought there might be something like that already written
<pattern>
but i wanted to write it myself
<pattern>
just for the practice
<pattern>
curious thing that even if i explicitly specify the type of the "l" argument like so: let rec applylist (l:('a -> 'a) list * 'a list ) = match l with
<pattern>
ocaml takes it but still reports that my function's typs is: val applylist : ('a list -> 'a list) list * 'a list list -> 'a list list = <fun>
<pattern>
so where did the extra list come from?
<pattern>
here's another weird behavior.... i did as kinners suggested and annotated the types of my makefnlist function:
<pattern>
let makefnlist (f:'D->('T1->'T2) as 'R) =
<pattern>
fun l -> let rec (fl:'D list -> 'R list) = function
<pattern>
[] -> []
<pattern>
| x::xs -> (f x)::(fl xs)
<pattern>
in
<pattern>
fl l
<pattern>
but ocaml tells me: This expression has type 'a -> 'b but is here used with type 'a -> 'a -> 'b
<pattern>
that's on the (f x) part
<pattern>
it's true that f should take two arguments
<pattern>
but i'm trying to do partial evaluation, and just give it one
<pattern>
isn't that how you achieve that?
<pattern>
i also tried: "let r = f x" and then "r::(fl xs)" instead of "(f x)::(fl xs)", but that didn't work any better
tomasso has quit [Read error: 110 (Connection timed out)]
<Kinners>
pattern: firstly, when you use []::[] you end up with [[]] not []
<pattern>
oh
<pattern>
that's weird
<pattern>
ok, so now in my applylist function i changed "[]::applylist (xs,[])" to "applylist (xs,[])" and that seemed to get the type i wanted :)
<pattern>
still, why didn't ocaml complain when the type signature i put in for "l", applylist's argument, disagreed with what ocaml determined it to be?
<pattern>
(that it had an extra list)
<Nutssh>
Map the result of applying the function I specified over a list and you have a function that goes from a list of functions and applies each of them to each element of a list.
<pattern>
nutssh, but wouldn't map only apply your function to each element of the list, not to the list as a whole? yet your function takes a list of functions as an argument
<pattern>
or are you just suggesting i use map with some function, not necessarily the one you specified?
<Nutssh>
Take the output of the helper function ('a -> 'a) and map it over the argument 'a list.
<pattern>
now why would i want to use the output of the helper function rather than just a regular function?
* pattern
is confused
<Nutssh>
What do you want again?
<Nutssh>
I thought you wanted something like ('a -> 'a) list -> 'a list -> 'a list
<pattern>
well, that was for the other thing i'm working on now, yes
<pattern>
i thought you were referring to the earlier problem
<Nutssh>
Oh. No. Not that.
<Kinners>
pattern: sorry, you actually need an extra set of parens around the ('T1->'T2) as 'R
<pattern>
ahh
<pattern>
now why is that?
<pattern>
and why didn't ocaml complain when it disagreed with my earlier type annotation of applylist's "l" argument?
<pattern>
great debuggin, by the way
<pattern>
i would have never figured it out
<pattern>
debugging
<Kinners>
pattern: I'm not exactly sure ;p
<pattern>
i'm thinking it's because 'D->('T1->'T2) as 'R means that it takes 'R to be a two argument function
<pattern>
whereas with the parenthesis 'R is a one argument function
<Kinners>
yeah, I'm not sure about the applylist thing
<pattern>
but then how does f turn in to a partially evaluated function?
<pattern>
(that is, once we specify 'R as you suggested, by only 'T1->'T2
<pattern>
)
<pattern>
oh, wait
<Kinners>
pattern: f is still 'a -> 'b -> 'c
<pattern>
but then why the complaint: This expression has type 'a -> 'b but is here used with type 'a -> 'a -> 'b
<Kinners>
pattern: or 'a -> 'a -> 'b, whatever :) we're just giving the 'a -> 'b an extra alias
<pattern>
oh i see
<pattern>
it really is 'a -> 'b
<pattern>
not f, but the result of applying f to x
<pattern>
ok, i'm with you now
<Kinners>
pattern: yeah, the problem was it was adding 'D to the alias, the extra 'a at the beginning
<pattern>
barely :) hanging on by a thread
<pattern>
yeah
<pattern>
really excellent work, kinners
<pattern>
how did you learn ocaml? did you take a class?
<Kinners>
I'm ill and unemployed so I've got plenty of time ;p
<pattern>
so you taught yourself, huh?
<pattern>
did you already know any other functional language?
<Kinners>
not really
<pattern>
me neither
<pattern>
so there's hope for me yet!
<Nutssh>
I learned sml-nj in undergrad.
<pattern>
ahh
<pattern>
in a class?
blueshoe has joined #ocaml
<Nutssh>
Yeah. CMU is one of the great functional language holdouts.
<pattern>
sounds like a fun school
<pattern>
no pun intended :)
<Nutssh>
It was. :)
blueshoe has quit [Read error: 104 (Connection reset by peer)]
blueshoe has quit [Read error: 104 (Connection reset by peer)]
<pattern>
for function f i've tried "[x]@y" as it's in there, and "x@y" and "x::y" and "[x]@[y]" and "[x@y]@y" and "[x@y]@[y]" and probably a bunch of other combinations but none of them work
<pattern>
i guess i'm just missing something
ott has joined #ocaml
<ott>
re all
<pattern>
hi
blueshoe has joined #ocaml
<async>
blueshoe: you go to berkeley?
<blueshoe>
i work there
<async>
cool, Smerdyakov and I are also in berkeley
<blueshoe>
i've actually met smerdyakov a week or so ago
<async>
where do you work?
<blueshoe>
evans
<blueshoe>
part of the bioengineering department
<async>
oh nice.. i have a couple discussions there
<blueshoe>
are you a student?
<async>
yeah
<blueshoe>
comp sci?
<async>
well, intended cs
<async>
im taking 61b right now
<blueshoe>
what's that?
<async>
its like lower-division stuff
<blueshoe>
i see
<blueshoe>
do they teach you any ocaml? :)
<async>
no, scheme
<blueshoe>
that's cool
<blueshoe>
sicp?
<async>
but i got a lot better at ocaml after learning scheme
<async>
oh yeah hehe
<blueshoe>
i've been meaning to learn scheme
<async>
you can learn it in 5 minutes
<blueshoe>
but first i've got to master ocaml :)
<blueshoe>
well, yeah, the basics
<async>
is it possible to master ocaml?
<blueshoe>
i think once i win the icfp i can safely say i've mastered it ;)
<async>
hehe
<async>
it seems the more i know about it, the more i have left to learn
<blueshoe>
well, i find the language itself to be pretty straight forward
<blueshoe>
it's making the most of it that's hard
<async>
well yeah... but stuff like camlp4 and polymorphic variants and stuff
<blueshoe>
so easy to just use the imperative style or just very simple constructs and waste its potential
<blueshoe>
yeah, camlp4 is something i haven't even looked in to yet
<blueshoe>
nor the oo features of ocaml
<blueshoe>
i hear camlp4 is pretty hairy, though... and almost no one ever uses it
<async>
it
<async>
i ust it for streams
<blueshoe>
why is that?
<async>
well camlp4 makes the stream syntax similar to lists
<blueshoe>
interesting
<blueshoe>
i wish there was an ocaml class i could take
Hadaka has quit [Read error: 110 (Connection timed out)]
Hadaka has joined #ocaml
<Nutssh>
Not sure what to say. I'm still learning the ocaml way, in particular, the object-way in ocaml.
karryall has joined #ocaml
<Nutssh>
I'd love to learn about creative ways of combinign functors, modules, and objects.
mimosa has joined #ocaml
<blueshoe>
"Chet Murthy had implemented support for call/cc
<blueshoe>
"There isn't any way to limit which introspective features a module uses, because Python has first-class functions. This means that you can pass in a function (potentially using arbitrary amounts of reflection) into a module, which has to execute it..."
<blueshoe>
"This is basically the reason call/cc is so controversial in the Scheme world: every program has to pay the price for its existence, even if they don't use it, because some downstream user might pass in a function that uses it."
<blueshoe>
comments, nutssh?
<teratorn>
Hmm, I don't know the first thing about call/cc, but I do know a thing or two about python.
<blueshoe>
reltuk: your link, he's comparing python to java & c/c++, which, as you'll see pointed out over and over again on lambda, make for poor champions of static typing
<teratorn>
reltuk?
<blueshoe>
?
<blueshoe>
oh
<blueshoe>
heh
<blueshoe>
it's the stupid nick completion on my irc client
<teratorn>
well sure ocaml is better than either of those in that respect
<teratorn>
but that doesn't change the argument.
<teratorn>
or well, once you've read the whole thing, and you think ocaml is way different, please tell me why :)
<blueshoe>
when i typed "re, your link" (with a colon in place of the dash here) my irc client thought i wanted to use nick completion and substituted the closest matching nick :(
<blueshoe>
s/dash/comma
<teratorn>
ah
<blueshoe>
"Issues of strong-vs-weak typing were not visible with Perl, since you can't build projects large enough to see these issues" <- false
<blueshoe>
but that's kind of beside the point
<teratorn>
oh it's quite true
<teratorn>
i've seen large projects in perl, oh too many times
<blueshoe>
and i really can't expect to see a python article without some perl bashing
<teratorn>
it's not a python article
<teratorn>
the same goes for ruby and smalltalk, at least, as he says. python is just an example.
<blueshoe>
they just heppen to mention python every other sentence
<teratorn>
blueshoe: you aren't a very nice person to discuss things with..
<blueshoe>
the guy's clearly a python advocate, and thus a perl basher ;)
<blueshoe>
:(
<teratorn>
blueshoe: gerneralizations suck.
<blueshoe>
"why are people able to build big, complex Python programs (with much shorter time and effort than the strong static counterparts)" <- proof please!
<teratorn>
i don't know how to *prove* it. can you prove the inverse?
a has joined #ocaml
<blueshoe>
i don't claim the inverse
<blueshoe>
the burden of proof is on he who makes the claim
a has quit [Client Quit]
<teratorn>
it can't be proven very easily at all, if at all.
<blueshoe>
then the author shouldn't make sweeping (trolling) statements if he can't prove them "at all"
<teratorn>
in the same sense that economic theory can't be proven or disproven except by a better theory.
ski has joined #ocaml
<blueshoe>
s/statements/allegations
<teratorn>
blueshoe: yeah, trolling, sure.
<teratorn>
whatever.
<blueshoe>
you don't consider that an inflammatory allegation?
<blueshoe>
one without **anything** to back it up (making it a classic troll, imo)
<teratorn>
why would/should I?
<teratorn>
nothing except experience.
<teratorn>
which is something I respect.
<blueshoe>
that big python programs take "much shorter time and effort" than statically typed language? come on... that's an inflammatory allegation if i've ever heard one
<teratorn>
even if it's true?
<blueshoe>
yes
<teratorn>
or is it false?
<blueshoe>
it's still an allegation
<blueshoe>
until **proven** to be true
<blueshoe>
or at least if he'd support it with some evidence
<blueshoe>
but he doesn't
<blueshoe>
he just throws it out as fact
<blueshoe>
which it's not
<teratorn>
blueshoe: well why don't you tell me what evidence he could cite!
<blueshoe>
like an example
<teratorn>
and I will send him an email telling him to put that in!
<teratorn>
blueshoe: the thing is chok full of examples. did you even read the fucking thing?
<teratorn>
this is no fun, i've got things to do, see ya later.
<blueshoe>
a big python app that did X compared to a program in a statically typed language that also did X, and the former was developed using "much shorter time and effort" than the latter, would be a good start
<blueshoe>
i don't see any examples of big python apps vs big apps in a statically typed language
<blueshoe>
just a few code snippets
<teratorn>
well go ahead and give me an example that proves it, or disproves it, as it were.
<blueshoe>
"Argument types and return types? Let the language sort it out!" <- again, this is not an argument against static typing... with type inference this is not a problem
<blueshoe>
by the way, i believe this article was discussed on lambda before
<teratorn>
"again" what?
<teratorn>
you think every sentence is an attack against static typing?
<blueshoe>
<teratorn> well go ahead and give me an example that proves it, or disproves it, as it were. <- i am not the one that made the claim that big python programs take "much shorter time and effort" than their counterparts in statically typed languages... the burden of proof is on him
<blueshoe>
until then i'll chalk it up to flamebait
<teratorn>
blueshoe: it would take a book dedicated the single question to prove it.
<teratorn>
probably a pretty big book.
<teratorn>
that book hasn't been written by anyone yet.
<blueshoe>
<teratorn> you think every sentence is an attack against static typing? <- "I was told that if I kept advocating unchecked exceptions, cities would fall and civilization as we know it would cease to exist." <- this and many of his other statements sure make it seem like that's what this article's about
<teratorn>
man, you are dense.
<teratorn>
of _course_ that is what the article is about, it even says so in the _freaking title_.
<teratorn>
that doesn't mean you should read each sentence as an attack against static typing, and then fault a sentence for _not_ attacking static typing, as you did.
<teratorn>
I'm trying to be nice here, but you're making it difficult :)
<blueshoe>
his point in that seemed to be that static typing added verbosity due to type annotations... but, you should know from using ocaml that with type inference this is not true... thus, again, his choice of champions of statically typed languages (c/c++ and java) is pretty poor
<blueshoe>
you're trying to be nice? <teratorn> man, you are dense.
<teratorn>
I didn't say I was succeeding.
<blueshoe>
well, you'll notice i made no personal attacks against you
<teratorn>
nor did I.
<teratorn>
"you are dense" is not an attack.
<blueshoe>
<teratorn> man, you are dense. <- not a personal attack?
<teratorn>
no.
<blueshoe>
oh, it's a compliment, is it?
<teratorn>
no.
<teratorn>
you are dense.
<ski>
(perhaps it might be misconstrued as an attack ?)
<blueshoe>
whyever would you think that?
<teratorn>
you're asking the man to prove what would take volumes of text and years of research, and when he's reluctant to do that, and instead just asks you to trust his experience, you write him off as flaimbait. I would call that dense.
<blueshoe>
i can smell it a mile away
<blueshoe>
trust my experience on that ;)
<teratorn>
but you don't have the experience.
<teratorn>
we've already established that.
<blueshoe>
well, i've programmed since 1980
<ski>
(perhaps blueshoe suspects he hasn't enough experience (e.g. with type inferencing))
<teratorn>
blueshoe: so what?
<blueshoe>
been on bbs' since early 80's
<blueshoe>
been on the net since '89
<blueshoe>
i'd say i've seen enough programming flamewars to know a troll when i see it
<teratorn>
blueshoe: try to stick to the topic at hand please.
<teratorn>
blueshoe: weeeeeel, lets just say he IS trolling.
<blueshoe>
and if you're willing to give this guy the benefit of the doubt for his unsubstantiated claim i don't see why you wouldn't extend me the same courtesy
<teratorn>
that doesn't prove nor disprove his theory.
<teratorn>
<teratorn> but you don't have the experience.
<teratorn>
<teratorn> we've already established that.
<teratorn>
that's why.
<blueshoe>
anyway, i see you're just as or even more willing to troll here
<teratorn>
hehe.
<blueshoe>
i don't know why i've let this go on this long
<teratorn>
I didn't bring it up, btw.
<teratorn>
I suggest you don't paste things that you don't want people to comment on in the future.
<blueshoe>
comment away
<blueshoe>
just don't be surprised when you hear a spade called a spade
<teratorn>
hm?
<blueshoe>
especially when that spade is an unsubstantiated, deliberately inflammatory statement
<blueshoe>
ie. troll
<ita>
ocaml sux
<ita>
:)
<teratorn>
how many fucking times do I have to repeat myself to get through to you?
<blueshoe>
that's "suxorz"
<teratorn>
<teratorn> blueshoe: weeeeeel, lets just say he IS trolling.
<teratorn>
<teratorn> that doesn't prove nor disprove his theory.
<blueshoe>
he proves nothing
<blueshoe>
he claims much
<blueshoe>
the burden of proof is on him
<blueshoe>
anyway, as i've said, this is clearly a waste of time
blueshoe has quit ["enjoy"]
<teratorn>
indeed.
<teratorn>
sorry I tried to help.
ski has quit [".. if I only had a brain .."]
karryall has quit [""manif""]
clog has joined #ocaml
ski has joined #ocaml
ski has left #ocaml []
mimosa has quit ["J'ai fini"]
Demitar has joined #ocaml
Nutssh has joined #ocaml
Nutssh has quit ["Client exiting"]
wazze has quit ["Learning about how the end letters on French words are just becoming more and more silent, I conclude that one day the French]
Nutssh has joined #ocaml
Nutssh has quit ["Client exiting"]
mattam_ has joined #ocaml
Smerdy has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
mattam has quit [Read error: 110 (Connection timed out)]
Smerdy is now known as Smerdyakov
yella has joined #ocaml
<yella>
hi
gim|570 has joined #ocaml
buggs|afk has joined #ocaml
buggs^z has quit [Read error: 60 (Operation timed out)]
cjohnson has quit [saberhagen.freenode.net irc.freenode.net]
rox has quit [saberhagen.freenode.net irc.freenode.net]
cjohnson has joined #ocaml
rox has joined #ocaml
lam has quit [Read error: 113 (No route to host)]
lam has joined #ocaml
reltuk has quit ["ERC Version 4.0 $Revision: 1.617 $ (IRC client for Emacs)"]
stepcut has joined #ocaml
<stepcut>
bah! int_of_string supports hex and octal, but string_of_int on supports decimal, what's up with that!
<Riastradh>
Tell the OCaml developers that their system sucks because of this and I'm sure they'll fix it immediately.
<stepcut>
they better! Or I'm switch to haskell!
<Riastradh>
Haskell's numeric outputting support isn't that great either.
<stepcut>
:p
<Riastradh>
Scheme's NUMBER->STRING supports an optional radix argument...
<stepcut>
scheme it is then
* Riastradh
points stepcut towards #scheme
<stepcut>
I'll just wait for pika
<Riastradh>
...you'll be waiting a while.
<Riastradh>
Why Pika and not Scheme48?
<Riastradh>
Scheme48 already exists.
<stepcut>
because then I wouldn't have anything to complain about
<Riastradh>
...isn't that a, um, good thing?
ita has quit [Remote closed the connection]
<stepcut>
well, maybe
<Riastradh>
I guess you'd no longer have an excuse not to be productive.
<stepcut>
well, currently I can still complain about how long it takes to rsync the entire kde.org cvs server