Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:15:36+00:00 2026-05-15T15:15:36+00:00

Given a number of functions test1 , test2 , … belonging to a module:

  • 0

Given a number of functions test1, test2, … belonging to a module:

module Checks =
    let test1 x = ...
    let test2 x = ...
    ...

how can the (?) operator be used to give access to both the function name and the function itself? The result should look like:

let name, func = Checks?test1
assert(name = "test1")
assert(func(x) = Checks.test1(x)) //whatever x is (test1 is known to be pure)
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:15:36+00:00Added an answer on May 15, 2026 at 3:15 pm

    Here’s some sample code that shows off some of this. I use D as the ‘dynamic’ access of the Checks module plus function name.

    module Checks = 
        let test1(x) = printfn "test1 %d" x
        let test2(x,y) = printfn "test2 %s %d" x y
    
    type MyDynamic() = class end
    let D = new MyDynamic()
    let (?) (md:MyDynamic) fname : (string * ('a -> 'r)) =
        let a = md.GetType().Assembly
        let t = a.GetType("Program+Checks")
        let m = t.GetMethod(fname)
        let f arg = 
            let at = arg.GetType()
            let fsharpArgs = 
                if at.IsGenericType && at.GetGenericTypeDefinition().FullName.StartsWith("System.Tuple`") then
                    Microsoft.FSharp.Reflection.FSharpValue.GetTupleFields(arg)
                else
                    [| box arg |]
            unbox(m.Invoke(null, fsharpArgs))
        fname, f
    
    let Main() =
        let x = 42
        let s = "foo"
        let name, func = D?test1 
        assert(name = "test1") 
        assert(func(x) = Checks.test1(x))
    
        let name, func = D?test2
        assert(name = "test2") 
        assert(func(s,x) = Checks.test2(s,x))
    
        System.Console.ReadKey()
    
    Main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can u give me a simple function in vb.net which can take number of
How can I check if a given number is even or odd in C?
I have written a function that gets a given number of random records from
I need a function count_permutations() that returns the number of permutations of a given
When i give wrong number of parameters in a function , i get errors.
Given a number, how do I discover in what table and column it could
I have a small math problem I am trying to solve Given a number
Given a week number, e.g. date -u +%W , how do you calculate the
Given a credit card number and no additional information, what is the best way
Given a sorted vector with a number of values, as in the following example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.