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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:06:41+00:00 2026-05-26T00:06:41+00:00

A further question about List: aaa :: [[(Char, Float)]] -> Float -> [[(Char, Float)]]

  • 0

A further question about List:

aaa ::  [[(Char, Float)]] -> Float ->  [[(Char, Float)]]
aaa [[]] a = error "no indata"
aaa [[(a,b)]] c = [[(a, b/c)]] 
aaa ([(a,b)]:tail) c = [(a, b/c)] : (aaa tail c)

How to make it work with:

aaa [[('a',3),('b',4),('c',5)],[('a',3),('b',4),('c',5)] ] 4

the result:

[[('a',0.75),('b',1),('c',1.25)],[('a',0.75),('b',1),('c',1.25)]]
  • 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-26T00:06:42+00:00Added an answer on May 26, 2026 at 12:06 am

    how about:

    > let l = [[('a',3),('b',4),('c',5)],[('a',3),('b',4),('c',5)] ]
    > let aaa list n = map (map (\(c,y) -> (c,(fromIntegral y) / n))) list
    > aaa l 4.0
    [[('a',0.75),('b',1.0),('c',1.25)],[('a',0.75),('b',1.0),('c',1.25)]]
    

    The types in your snippet down match. You try to apply functions defined on float on integers.
    You have to pass floats to the functions. That’s why i convert the integers with (fromIntegral y) to floats before applying the floating point division “/” on them. The second argument has to be a floating point number too, so use 4.0 instead of 4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Extending a previous question about JavaScript and jQuery, I'm trying to make an array
Further to my question on disabling validators using javascript - Disable ASP.NET validators with
Taking shs's question a step further... Why isn't all government sponsored software open source?
I'm quoting myself on a previous question I asked to further explain: I'm trying
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
A quick question about best practice with PHP classes. I have seen people use
I just asked a question here about selecting all id's of the form id_*
I have a question about generics. I have a function that knows about a
Since this question is about the increment operator and speed differences with prefix/postfix notation,
I've been reading about foreach and list iteration, and I understand how to set

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.