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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:09:54+00:00 2026-06-15T22:09:54+00:00

I have the following code in haskell that i want to make some changes

  • 0

I have the following code in haskell that i want to make some changes to it:

 unwords . map (printf "%02X") $ zipWith (\x y -> -(fromIntegral (ord x)) + y - 2 :: Word8) "Aa123456" [0..]

After running this code i get:

"BD 9E CF CF CF CF CF CF"

Basically i want the inverse of this function, so the function can get the hex values "BD 9E CF CF CF CF CF CF" and return "Aa123456".

I am sure i would have to change the printf statement but how i am suppose to change the script to accept the hex values ?

  • 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-06-15T22:09:55+00:00Added an answer on June 15, 2026 at 10:09 pm

    As @gspr suggests, the way to solve this is to break it into smaller parts:

    1. isolating each hexadecimal from the string, i.e. turning "BD 9E CF CF CF CF CF CF" into ["BD", "9E", ...., "CF", "CF"].
    2. converting a hexadecimal string into an integer, e.g. “BD” -> 189
    3. converting each integer into the appropriate character, e.g. 189 -> “A”

    For 1, the words function might help.

    For 2, read "0xBD" == 189. You just need to work out how to get each hexadecimal number into the right format for read. (Note, that you could also write your conversion function to go directly from string to integer, it might be a nice little bit of practice.)

    For 3, just invert the encoding operation, i.e.: write your equation i = y - x - 2 (mod 256) (where i is the one converted from hexadecimal, and y is the index in the list, and x is the value of the character) and solve for x. And chr is the inverse to ord.

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

Sidebar

Related Questions

I have some Haskell code that does work correctly on an infinite list, but
I have following code that I am compiling in a .NET 4.0 project namespace
I have the following haskell code: fac n = product [1..n] taylor3s w0 f
I have following code: #include <stdio.h> // For printf() #include <sys/stat.h> // For struct
I have some troubles with Haskell's type system. Situation: Following program is taking list
I have the following Haskell code: -- Problem 69 import ProjectEuler phi :: Integer
I have the following haskell code to expand environment variables in strings (parsing code
I have the following Template Haskell code in my module, which is part of
I have written a script in haskell named testscript with the following code: #!/usr/bin/env
I have a problem with a Haskell code, I have the following: takeMeHere cs

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.