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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:45:37+00:00 2026-05-22T17:45:37+00:00

I have the following grid: [[a1,b1, c1,d1], [a2,b2, c2,d2], [a3,b3, c3,d3], [a4,b4, c4,d4]] and

  • 0

I have the following grid:

[["a1","b1",    "c1","d1"],
 ["a2","b2",    "c2","d2"],

 ["a3","b3",    "c3","d3"],
 ["a4","b4",    "c4","d4"]]

and would like to extract a range of values in their ‘squares’ so I end up with a list of square values. The x-values are horizontal and y-values are vertical.

I have the following function started:

type Coordinate = (Int,Int)

return :: [[String]] -> Coordinate -> [String]
return grid (x,y) = .....

where (0,0) is the top left corner of the grid. Using the above function I would like to be able to extract a square so I get like this (if my coordinates are (2,0), (3,0), (2,1), (3,1)):

["c1","d1","c2","d2"]

I have tried some methods including the map function but need some tips on how to proceed.

  • 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-22T17:45:38+00:00Added an answer on May 22, 2026 at 5:45 pm

    I suggest the following:

    localSquare :: [[a]] -> (Int,Int) -> [[a]]
    localSquare xss (x,y) = map (take y . drop n) $ (take x . drop n) xss
      where n = length xss `div` 2
    
    matrix = replicate 10 [1..10]
    

    applied:

    > localSquare matrix (5,5)
    [[6,7,8,9,10],[6,7,8,9,10],[6,7,8,9,10],[6,7,8,9,10],[6,7,8,9,10]]
    

    If you indeed need a plain list, apply just type concat $ localSquare matrix (5,5)

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

Sidebar

Related Questions

I have the following code to filter a grid from values inputed in a
Good day all I have the following question: I would like to use Chart
I have the following grid defined: $(#list).jqGrid({ url:'listOpenQueryInXML.php', datatype: 'xml', colNames:['Id','name1', 'name2', 'status', 'type'],
I have the following XAML in a WPF application. I would like to bind
I would like the following functionality: I have a datagrid, and when I go
I have following user control: <UserControl.Resources> <Style TargetType=HeaderedItemsControl> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType=HeaderedItemsControl> <Grid>
I have the following call to load a grid: $(#searchlist).jqGrid({ url:'./searchlibrary', datatype: 'json', mtype:
Suppose I have the following (shortened for simplicity): jQuery(#grid).jqGrid({ ... ondblClickRow: function() { //
I have defined following control template for my custom control. <ControlTemplate TargetType={x:Type local:CustomControl}> <Grid
I'm building a grid in ASP.NET MVC and I have the following issue: Above

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.