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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:14:00+00:00 2026-05-12T11:14:00+00:00

I am attempting to learn J and the book I am using says this

  • 0

I am attempting to learn J and the book I am using says this is the proper way to define a monadic function

function =: 3:0 
    function statements

so I followed this format and wrote the folding code. Can you tell me why this is throwing a syntax error when I try to call it with input but if I just call p it returns 3

h=:>:@i.@<.@-: :[: NB. gets all integers less than half of the input :[: forces error if used dyadicly
d=:(0&=|)~ h :[: NB. gets list where if one is set that index from h was a factor of the input y  :[: forces error if used dyadicly
p=: 3:0 NB. tells us p is a monadic function
   t =: d y 
   a =: i. 1
   while. 1<#t
      if. t~:0
         a =: a, #t
      end.
      t=: _1 }. t NB. found first mistake wrong bracket but fixing that doesn't fix it
   end.
   a*1
) 

NB. p gets a list of all integers that are factors of y
p 4
| syntax error
| p 4
p
3
NB. h and d run fine
h 4
    1 2
h 7
    1 2 3
d 7
    1 0 0
d 4
    1 1
  • 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-12T11:14:00+00:00Added an answer on May 12, 2026 at 11:14 am

    Firstly, 3:0 parses like (3:) (0), i.e. the monad “3:” applied to the noun “0“. That’s not what you want; for definitions, you want to use the dyad “:“, so you need to separate it from the 3 with a space.

    Secondly, you should use =. instead of =: inside the definition, as t and a are local variables.

    Several parts can be simplified:

    d =: 0 = h | [             NB. does h y divide y
    p =: d # h                 NB. select d y from h y
    

    Same functionality as before, but clearer and faster.

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

Sidebar

Related Questions

I'm attempting to learn how to use Cucumber and creating steps using the following
I'm following this tutorial attempting to learn XNA, but I'm having issues making my
I am attempting to learn to create graphs using Telerik. At the moment I
Disclaimer: This may be a terribly simple question but I'm attempting to learn Python.
I am attempting to learn more about this to implement in my project. I
I am attempting to learn OCaml by using compiled code instead of the top-level;
I have been attempting to learn Grails, however I am running into the following
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be
I've been attempting to learn programming (in C#) for a few years now. The
I'm attempting to learn Scala so I have decided to implement datastructures with it.

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.