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 6945077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:23:22+00:00 2026-05-27T13:23:22+00:00

I want to find maximum, minimum and average in an array without .NET in

  • 0

I want to find maximum, minimum and average in an array without .NET in F#.
I used this code but it is not working:

let mutable max = 0
let arrX = [|9; 11; 3; 4; 5; 6; 7; 8|]

for i in 0 .. arrX.Length - 2 do
  if (arrX.[i]) < (arrX.[i+1]) then 
       max <- arrX.[i]
       printfn "%i" max
  • 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-27T13:23:23+00:00Added an answer on May 27, 2026 at 1:23 pm

    I fixed your code for max

    let mutable max = 0
    let arrX= [|9; 11; 3; 4; 5; 6; 7; 8|]
    
    for i in 0 .. arrX.Length - 1 do
      if max < (arrX.[i]) then 
           max <- arrX.[i]
           printfn "%i" max
    

    To find max, min and avg, using your approach:

    let mutable max = System.Int32.MinValue
    let mutable min = System.Int32.MaxValue
    let mutable sum = 0
    let arrX= [|9; 11; 3; 4; 5; 6; 7; 8|]
    
    for i in 0 .. arrX.Length - 1 do
      if max < (arrX.[i]) then 
           max <- arrX.[i]
           printfn "max %i" max
      if min > (arrX.[i]) then 
           min <- arrX.[i]
           printfn "min %i" min
      sum <- sum + arrX.[i]
    printfn "-> max is %i" max
    printfn "-> min is %i" min
    printfn "-> avg is %f" (float sum / float arrX.Length)
    

    But note you can do just:

    let max = Seq.max arrX
    let min = Seq.min arrX
    let avg = Seq.averageBy float arrX
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code is about to find maximum element from an array i want to
I want to find a sql command or something that can do this where
I want to find an SQL query to find rows where field1 does not
I have an NSArray of NSNumbers and want to find the maximum value in
I want to use max clause to find the maximum value according to field
I am trying to find a O (n) algorithm for this problem but unable
I want to find the maximum value from the List objects.The class structure is
I want to find a nonempty, contiguous subarray for a given input array of
I'm trying to find the minimum spanned tree using Mathematica and I want to
I want to find the minimum between the line number 2000 and 3000. I

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.