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

  • SEARCH
  • Home
  • 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 1044025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:45:41+00:00 2026-05-16T15:45:41+00:00

In simple words, I want to implement a function like that: let myfunction (scalar

  • 0

In simple words, I want to implement a function like that:

let myfunction (scalar : float) (quantities : ''T list) = 
    List.fold (fun acc quantity -> acc + quantity * scalar)
        LanguagePrimitives.GenericZero<_>
            quantities : 'T

Note that I am multiplying a value of generic type 'T and a float value (quantity * scalar) which should return a value of type 'T. For example, multiplying a Point by a scalar result in a Point.

I cannot make F# understand that the multiplication quantity * scalar should result in a value of type 'T. I tried LanguagePrimitives.MultiplyDynamic, but it seems that this function is reserved to be used by the F# compiler.

What should I do?

  • 1 1 Answer
  • 0 Views
  • 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-16T15:45:41+00:00Added an answer on May 16, 2026 at 3:45 pm

    Is there any reason to specialize to the case where scalar is a float? I think your best bet is to generalize even further:

    let inline myfunction scalar quantities =  
        List.fold (fun acc quantity -> acc + quantity * scalar)
            LanguagePrimitives.GenericZero<_>
            quantities 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the Requirement in simple words goes like this. Its a charting Application ( kinda
Can anyone tell me in simple words that what this L value is and
I have a simple autocomplete field that spits out a bunch of suggested words
I'm trying to implement a simple search function. I have a string array which
I have a class template Foo<T> . I'd like to implement a non-member function
I want to show some bold and some simple word within the same sentence.If
I wrote this as a simple dice game. It works as I want except
Can you explain it in most simple words? Best with a demo script.
Please guide what is meaning by Web is stateless in simple words ? Kindly
There's a simple string manipulation problem where you are required to reverse the words

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.