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

The Archive Base Latest Questions

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

Consider this: map fromEnum $ zipWith (==) aaaa abaa — [1,0,1,1] It would be

  • 0

Consider this:

map fromEnum $ zipWith (==) "aaaa" "abaa"
-- [1,0,1,1]

It would be nice to have only one step here:

zipWith (\x y -> fromEnum (x == y)) "aaaa" "abaa"

Now I can eliminate y:

zipWith (\x -> fromEnum.(x ==)) "aaaa" "abaa"

But I fail to eliminate x. Of course there are ways to “cheat”…

zipWith (curry (fromEnum . uncurry (==))) "aaaa" "abaa"

… but this looks uglier than the original lambda.

The function I look for would be somewhat similar to Data.Function.on, but “the other way around”. I have the feeling that there is an embarrassingly simple solution for this. Do I overlook something?

  • 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:45:16+00:00Added an answer on May 26, 2026 at 12:45 am
    zipWith (\x -> fromEnum . (x ==)) "aaaa" "abaa"
    

    can be written as

    zipWith (\x -> (fromEnum .) (x ==)) "aaaa" "abaa"
    

    which can be written as

    zipWith ((fromEnum .) . (==)) "aaaa" "abaa"
    

    If you find this readable depends on taste I guess.

    EDIT: Another nice way to do it is with some combinators by Matt Hellige:

    zipWith ((==) $. id ~> id ~> fromEnum) "aaaa" "abaa"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this program: #include <map> #include <vector> typedef std::vector<int> IntVector; typedef std::map<IntVector,double> Map; void
Consider this problem: I have a program which should fetch (let's say) 100 records
I have a small isuse regarding an interface. Consider this code: [HttpPost()] public void
consider this translation unit: #include <map> #include <string> int main() { std::map<std::string, std::size_t> mp;
Consider this example (typical in OOP books): I have an Animal class, where each
I need help with one of the Groovy 1.8 DSL features. Consider this test
Consider this Map[String, Any] : val m1 = Map((k1 -> v1), (k2 -> 10))
Consider this definition object: var map = { 'Username': { 'user-name': 'userName', 'first-name': 'fName',
Consider this small snippet of JavaScript: for(var i in map.maps) { buttons.push($(<button>).html(i).click(function() { alert(i);
Given the following SUT, would you consider this unit test to be unnecessary? **edit

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.