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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:50:22+00:00 2026-06-19T02:50:22+00:00

I would like to apply a function to all the tuples in an ETS

  • 0

I would like to apply a function to all the tuples in an ETS table :

The table is a set, each key appears only once.

My table contains only tuples of the same type:

{Key, X, Y, VX, VY}

All values are ::integer()

What i want to do is have a certain value Elapsed and update all
my tuples with a function apply_vector/2

apply_vector({K, X, Y, 0, 0}, _Elapsed) ->
    {K, X, Y, 0, 0};

apply_vector({K, X, Y, VX, VY}, Elapsed) ->
    NewX = X + (VX * Elapsed),
    NewY = Y + (VY * Elapsed),
    {K, NewX, NewY, VX, VY}.

Possible solutions

  • If i use ets:foldl, my inserts could be traversed during the fold, and
    result in an infinite (very long) loop.

  • I could prepare the new tuples with a ets:foldl, and then insert the whole
    list.

  • I could insert to a new table, then replace the old table by the new,
    but i don’t want to limit access to the table with calls to a
    gen_server, the table must be accessible at any time.

  • I can not use ets:update_element because I need to read VX and VY values
    to update X and Y.

  • I know there are some iterators utilities but no one seems to allow to
    pass a fun.

I need to make this update every 1 – 5 seconds. So, wich solution is
the most efficient with 10 tuples ? With 100 tuples ? With more ?

Thank You !

I Keep a list of boats, the Key is the Boat ID, X and Y are geographic
coordinates, VX and VY represents a vector of movement: a deplacement
for one second. Elapsed is a ratio, a number of seconds since the last
update. The table helps to know at any time the position of each boat.

  • 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-19T02:50:23+00:00Added an answer on June 19, 2026 at 2:50 am

    I probably use ets:foldl for this.

    Seems to me like you only need iterative access on this data. So you could just use list of records here.

    Another approach (which I would go for) is to put a boat supervisor and create a gen_server for every boat. That way every boat will have its own state and you won’t actually need to traverse any list.

    Also checkout qlc http://www.erlang.org/doc/man/qlc.html
    qlc let’s you use list comrehensions on ets or mnesia tables. It will probably have the same performance as foldl though.

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

Sidebar

Related Questions

I have a dataframe and I would like to apply a function that takes
I have this line: $(#clients-edit-wrapper).height($(window).height()-150); I would like to apply that height function to
I would like to apply FileIOPermission on set of files using mask in file
I would like to apply a function to a Java collection, in this particular
I would like to implement a diagonal matrix apply function that is created by
I would like to know if it is possible to apply a function to
I would like to apply transition rules to elements with javascript, so far this
I would like to apply successive animations (say ScaleAnimation) to an ImageView showing a
I would like to apply a css file after choosing an option from a
I would like to apply a background-color style conditionally in the itemTpl of a

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.