0

“Add the option -f to fold upper and lower case together, so that case distinctions are not made during sorting; for example, a and A compare equal.”

Excerpt From: Brian W. Kernighan. “The C Programming Language, Second Edition.

I am not sure what this means exactly. I was thinking about two options:

  • convert all uppercase to lowercase letters or vice versa
  • keep the cases as they are and merely treat them as equal

Does the expression to fold something together in this case have a specific meaning?
Or am I free to choose an interpretation?

3
  • The clause so that case distinctions are not made during sorting; for example, a and A compare equal defines what folding means here. – Jim Jan 3 '16 at 2:24
  • So merely treat them as if they were equal, but not turning them into equal? I am not sure if I am understood. Do you know what I mean? – Ely Jan 3 '16 at 2:27
  • 1
    Correct. Treat them as equal but do not change them. Thus, the set: { BB,ba,aB,cA,Cb,Aa,CC,ac} would sort to: {Aa,aB,ac,ba,BB,cA,Cb,CC} and not {ac,aB,ba,ca,Aa,BB,Cb,CC}. – Jim Jan 3 '16 at 2:35
3

This is from an exercise in C programming, in which the student is asked to modify a line sorting program. "Fold together" here means to treat each lower-case letter and its corresponding upper-case letter as the same value for purposes of the sort.

3
  • So merely treat them as if they were equal, but not turning them into equal? I am not sure if I am understood. Do you know what I mean? – Ely Jan 3 '16 at 2:27
  • 1
    I think so. The program sorts the lines as though all uppercase letters were lowercase letters but outputs the lines unchanged. – deadrat Jan 3 '16 at 3:19
  • Yes, "fold" was an unfortunately poetic choice of words, especially for a manual, because it implies action where there is no action. The only action is the reordering of the entries. – lauir Jan 3 '16 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.