Skip to main content
Commonmark migration
Source Link

#J, 15 7 chars, 1 tie breaker, incomplete program

J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

##More of a program

More of a program

This one queries for input, but it still isn't a full program: (13 chars, 3 breakers)

##~".1!:1<#a:

#J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

##More of a program

This one queries for input, but it still isn't a full program: (13 chars, 3 breakers)

##~".1!:1<#a:

J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

More of a program

This one queries for input, but it still isn't a full program: (13 chars, 3 breakers)

##~".1!:1<#a:
added 133 characters in body
Source Link
FUZxxl
  • 10.1k
  • 1
  • 38
  • 81

#J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

##More of a program

This one queries for input, but it still isn't a full program: (13 chars, 3 breakers)

##~".1!:1<#a:

#J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

#J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

##More of a program

This one queries for input, but it still isn't a full program: (13 chars, 3 breakers)

##~".1!:1<#a:
deleted 28 characters in body
Source Link
FUZxxl
  • 10.1k
  • 1
  • 38
  • 81

#J, 1515 7 chars, 31 tie breakersbreaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:[:#[:;<@i."0#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'#;<@i."0y''##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the input toparameter of p.
  • i. x~ generates an integer sequence upmakes a verb reflexive. For some verb xm. For instance, i.m~ 5a givesis equal to 0 1 2a 3m 4a.
  • "0# applies a function to each(copy, a#b): Each element of a list.
  • in @a is composition
  • replicated <i boxes the resulting sequence. If I would not do thattimes, I would get an array with to many elements
  • Sowhere <@i."0i makes a boxed list of given length for each listis the element at the same index as the current element of a of b. Notice thatThus, <#~ binds stronger thanreplicates an item "n
  •    ;n unboxes and concatenates the subliststimes.
  • # counts the elements of the list(count, yielding#b): Counts the resultnumber of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.

#J, 15 chars, 3 tie breakers, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:[:#[:;<@i."0

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'#;<@i."0y'
  • y is the input to p
  • i. x generates an integer sequence up x. For instance, i. 5 gives 0 1 2 3 4
  • "0 applies a function to each element of a list.
  • @ is composition
  • < boxes the resulting sequence. If I would not do that, I would get an array with to many elements
  • So <@i."0 makes a boxed list of given length for each list element. Notice that < binds stronger than "
  •  ; unboxes and concatenates the sublists
  • # counts the elements of the list, yielding the result

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

#J, 15 7 chars, 1 tie breaker, incomplete program

This is my J attempt. It is not a full program, because I have not yet figured out how to write one. Just put that line in a script to get the function p that can be used for adding an arbitrary amount of numbers. It is a monad and takes a list of numbers to add (such as p 1 2 3 4):

p=:#@#~

The idea is very simple. The function is written in tacit aka pointless style. Here is a pointed definition:

p=:3 :'##~y'

Read from right to left. In the tacit version, @ composes the parts of the function. (like a ∘ in mathematics [(f∘g)(x) = f(g(x)])

  • y is the parameter of p.
  • ~ makes a verb reflexive. For some verb m, m~ a is equal to a m a.
  • # (copy, a#b): Each element in a is replicated i times, where i is the element at the same index as the current element of a of b. Thus, #~ replicates an item n  n times.
  • # (count, #b): Counts the number of elements in b.

Conclusion: J is awsome and less readable than Perl (that makes it even more awsome)

##Edits

  • 15 -> 7 using # instead of i.. Yeah! Less chars than golfscript.
added 730 characters in body
Source Link
FUZxxl
  • 10.1k
  • 1
  • 38
  • 81
Loading
Source Link
FUZxxl
  • 10.1k
  • 1
  • 38
  • 81
Loading