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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:14:06+00:00 2026-05-10T16:14:06+00:00

Suppose I want to implement a reasonably efficient ‘keyword recognition algorithm’, that is first

  • 0

Suppose I want to implement a reasonably efficient ‘keyword recognition algorithm’, that is first given a list of keyword, and must then answer if another given word was in the list.

In an imperative language, I would store the keywords in a tree (one node per character). Then, when receiving a word to test, I would scan my tree to test if the word is a keyword.

I’d like to understand how such an algorithm would be coded in a functional language. How does one get the benefits of ‘stateless’ programming while keeping the efficiency of ‘imperative’ algorithms. Isn’t it necessary to store the tree somewhere between the lookups if you don’t want to rebuild it each time?

  • 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. 2026-05-10T16:14:07+00:00Added an answer on May 10, 2026 at 4:14 pm

    I think what you mean is a character per node… sort of like a simple hash tree scheme for keyword lookup. Assuming this or even another kind of tree… imagine doing something like this (in pseudo-LISP):

    (defun buildtree (wordlist) ...code to build tree recursively returns the tree...) (define lookup (tree word) ...code to look up word using tree, returns t or nil...)  (defun lookupmany (tree querylist)    (if (eq querylist nil)        nil        (cons (lookup tree (car querylist)) (lookupmany tree (cdr querylist))    ) )  (defun main (wordlist querylist) ; the main entry point    (lookupmany (buildtree wordlist) querylist) ) 

    if this is what you mean, this is fairly straight-forward functional programming. Is it really stateless? That’s a matter of debate. Some people would say some forms of functional programming store what we normally call ‘state’ on the stack. Moreover, Common LISP even since the first edition of the Steele book has had iterative constructs, and LISP has had setq for a long, long time.

    But in the theory of programming languages, what we mean by ‘stateless’ is pretty much satisfied by the idea shown here.

    I think the above is something like the arrangement you mean.

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

Sidebar

Ask A Question

Stats

  • Questions 88k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes. Oracle calls them collections and there's a variety of… May 11, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer I don't know if this is what you are looking… May 11, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer (Aside: This seems like something that the upstream Makefile ought… May 11, 2026 at 5:40 pm

Related Questions

Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first
This really, really urks me, so I hope that someone can give me a
After the previous question What are the important rules in Object Model Design, now
C++/CLI helpfully generates the IDisposable scaffolding for you when you implement a destructor on
I am using LINQ and am having a hard time understanding how I can

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.