This is because the code you entered is a partial application.

The complete signature of the function is :

1
2
String.map_concat ;; 
val it : ((char -> string) -> string -> string) = <fun:clo@0>

The output you get means that the code you entered is a partial application, and therefore the result you get is a new function. That is, if you write

1
2
3
4
5
 
let f = String.map_concat (fun d -> 
            if String.rcontains_from "abcd" 4 'd' 
            then "a" + String.of_char(d) 
            else String.of_char(d))

You can then write :

1
 f mystring

.

The change of id is only related, I think, to where it's stored by the fsi.

Hope this helps

Edit: We posted at the same time (roughly), and I obviously was too slow! Sorry for the duplicate explanation!

By on 4/15/2008 2:45 PM ()

This is because the code you entered is a partial application.

The complete signature of the function is :

1
2
String.map_concat ;; 
val it : ((char -> string) -> string -> string) = <fun:clo@0>

The output you get means that the code you entered is a partial application, and therefore the result you get is a new function. That is, if you write

1
2
3
4
5
 
let f = String.map_concat (fun d -> 
            if String.rcontains_from "abcd" 4 'd' 
            then "a" + String.of_char(d) 
            else String.of_char(d))

You can then write :

1
 f string1 string2

.

The change of id is only related, I think, to where it's stored by the fsi.

Hope this helps

Edit: We posted at the same time (roughly), and I obviously was too slow! Sorry for the duplicate explanation!

Many thanks for your explanation. But I just found that I should write -

1
String.rcontains_from "abcde" 4 'd'

if I really want to keep the Index 4, othterwise, I will get "OutOfBoundary" Error @_@

By on 4/16/2008 2:11 AM ()

String.map_concat takes two arguments: a function that accepts a char and gives a string (char -> string) and a string to operate on. You're only passing it the first, so you're getting a new function back.

That <fun:it...> means you've gotten a function back, in this case a partial application of String.map_concat.

By on 4/15/2008 2:45 PM ()

String.map_concat takes two arguments: a function that accepts a char and gives a string (char -> string) and a string to operate on. You're only passing it the first, so you're getting a new function back.

That <fun:it...> means you've gotten a function back, in this case a partial application of String.map_concat.

Thanks a lot for your answer. :)

By on 4/16/2008 1:57 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper