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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:35:13+00:00 2026-05-22T01:35:13+00:00

I found a good article , about call with current continuation patterns. As I

  • 0

I found a good article, about call with current continuation patterns. As I understand, they use Scheme and undelimited continuations. Can the patterns from the article be implemented in Scala? Is there any article about delimited continuations patterns in Scala ?

  • 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-22T01:35:14+00:00Added an answer on May 22, 2026 at 1:35 am

    Yes, they absolutely can. callCC looks like this in Scala:

    def callCC[R, A, B](f: (A => Cont[R, B]) => Cont[R, A]): Cont[R, A] =
      Cont(k => f(a => Cont(_ => k(a))) run k)
    

    Where Cont is a data structure that captures a continuation:

    case class Cont[R, A](run: (A => R) => R) {
      def flatMap[B](f: A => Cont[R, B]): Cont[R, B] =
        Cont(k => run(a => f(a) run k))
      def map[B](f: A => B): Cont[R, B] =
        Cont(k => run(a => k(f(a))))
    }
    

    Here’s how you might use it to simulate checked exceptions:

    def divExcpt[R](x: Int, y: Int, h: String => Cont[R, Int]): Cont[R, Int] =
      callCC[R, Int, String](ok => for {
        err <- callCC[R, String, Unit](notOK => for {
                 _ <- if (y == 0) notOK("Denominator 0") else Cont[R, Unit](_(()))
                 r <- ok(x / y)
               } yield r)
        r <- h(err)
      } yield r)
    

    You would call this function as follows:

    scala> divExcpt(10, 2, error) run println   
    5
    
    scala> divExcpt(10, 0, error) run println
    java.lang.RuntimeException: Denominator 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found a very good article about how to use EntLib Validation Block for
I found an article on About.com that tells you how you can manage your
I was browsing and found good articles about encryption. However, none of them described
I found this article about simple proxy server implemented in JAVA: http://www.java2s.com/Code/Java/Network-Protocol/Asimpleproxyserver.htm The code
Anyone found a good pattern for getting around immutable styles in Silverlight 2? What
I found a good description on wikipedia with a few reference links, but there
Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a
Has anyone found a good method of mocking out ADO.Net Data Service calls from
I once did a cursory search and found no good CVS bindings for Python.
I've searched the Internet and have found some good solutions for teeing STDOUT to

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.