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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:49:33+00:00 2026-05-24T03:49:33+00:00

Sometimes my APL familiarity gives me algorithmic ideas for problem solving that I re-implement

  • 0

Sometimes my APL familiarity gives me algorithmic ideas for problem solving that I re-implement in a language I have – Perl, for example.

So I have processed a text file to create a boolean vector indicating the used fields in a delimited file, and now I want to output the indexes of those used fields, and the names of the used fields. In APL, I would use the compress operator over the vector of field names, and over the iota of the number of fields.

In Perl, I did this:

my @UsedFieldNames = map { $UsedFields[$_] ? $FieldNames[$_] : () } 0 .. $#UsedFields;

and

say join " ", map { $UsedFields[$_] ? $) : () } 0 .. $#UsedFields;

where @UsedFields is an array containing 0 for unused and 1 for used fields.

  1. I don’t really like using map with ?:() to simulate compress – is there a better way (my real program does it a third time when simulating a vertical or reduction over the file)?

  2. I don’t really like doing the map over the indexes to get the results – is there a better way to compute that? (I guess one optimization would be to compute the used indexes first, then

    @UsedFieldNames = @FieldNames[@UsedIndexes];

  • 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-24T03:49:33+00:00Added an answer on May 24, 2026 at 3:49 am

    Other ways:

    my @UsedFieldNames = map { ( $FieldNames[$_] ) x !!$UsedFields[$_] } 0..$#UsedFields;
    my @UsedFieldNames = @FieldNames[ grep $UsedFields[$_], 0..$#UsedFields ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I have to work on code that moves the computer clock forward. In
Sometimes I have come across this issue that whenever I change the order of
sometimes there are sites that have some small information window thats always visible when
Sometimes I have to test some javascript code, that I use jsbin.com , but
Sometimes coloring a logfile or other gives a good overview when looking for stuff
Sometimes I have a true colored image, by using dithering algorithm, I can reduce
Sometimes I get errors that I suspect are the result of my Django app
Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example,
Sometimes for example I change a word in line 100 and delete last 4
Sometimes I need to implement an obj's hashCode() method by combining the hashCodes of

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.