NYCJUG/2015-03-10

From J Wiki
Jump to navigation Jump to search
             Meeting Agenda for NYCJUG 20150310
             ----------------------------------

1. Beginner's regatta: See "Reversing a String" - would the J "|." be intriguing as an
introduction to an essay, like the following, that emphasizes notation and array-thinking?

See "2D Probability Distribution Plot".


2. Show-and-tell: See "Working with Large Covariance Arrays"

Similarly, might an introduction like this one - "Displaying and
Working with Matrixes" - be a useful adjunct to the array-thinking
part of this exercise above?


3. Advanced topics: various topics in graphics - problems running under
jconsole: see "Low-level graphics with wd and jgl" and "Updates to Isigraph".

See "Threading / Multiple J Instances".


4. Learning and teaching J: See "The Highest-Paying Programming Languages".

           +.--------------------+.

It is not worth an intelligent man's time 
to be in the majority. By definition, 
there are already enough people to do that.
  - G. H. Hardy

Meeting Agenda for NYCJUG 20220509

Beginner's regatta

Reversing a String

A search on the web for how to reverse a string in Excel returned the following examples. [From http://www.excel-easy.com/vba/examples/reverse-strings.html]

Dim text As String, reversedText As String, length As Integer, i As Integer
text = InputBox("Enter the text you want to reverse")
length = Len(text)
For i = 0 To length - 1
    reversedText = reversedText & Mid(text, (length - i), 1)
Next i

This brings up a dialog box that allows you to enter the string by hand. --- [From http://www.extendoffice.com/documents/excel/1146-excel-reverse-string-word-order.html#a2] Here we have two methods: one using a formula, the other using a VBA module that requires you to enter the range on which to work; this one replaces the existing text.

=IF(LEN(A1)<1,"",MID(A1,LEN(A1),1))&IF(LEN(A1)<2,"",MID(A1,LEN(A1)-1,1))&IF(LEN(A1)<3,"",MID(A1,LEN(A1)-2,1))&IF(LEN(A1)<4,"",MID(A1,LEN(A1)-3,1))&IF(LEN(A1)<5,"",MID(A1,LEN(A1)-4,1))

And

Sub ReverseText()
'Updateby20131128
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
xValue = Rng.Value
xLen = VBA.Len(xValue)
xOut = ""
For i = 1 To xLen
getChar = VBA.Right(xValue, 1)
xValue = VBA.Left(xValue, xLen - i)
xOut = xOut & getChar
Next
Rng.Value = xOut
Next
End Sub

--- [From http://excelexperts.com/reverse-string]

Perhaps the best of the lot, this uses a formula similar to the one above, though it is sensitive to the length of the string, returning an incorrect result if the length is not 5, though it is easily extendable.

=LEFT(RIGHT(A1,1),1)&LEFT(RIGHT(A1,2),1)&LEFT(RIGHT(A1,3),1)&LEFT(RIGHT(A1,4),1)&LEFT(RIGHT(A1,5),1)

Reversing a String in J

In J, we use “|.” to reverse a string:

  |. 'hallelujah!'

!hajulellah

Of course, this works with other vectors as well:

   |. 1 2 3
3 2 1

It also applies to higher-dimensional arrays in the same way as all similar J verbs:

   ]mat=. 'Madam','I''m',:'Adam'
Madam
I'm  
Adam 
   |.mat
Adam 
I'm  
Madam

Like other verbs, it can also be modified with the “rank” conjunction to change how it is applied:

   |."1 |.mat
 madA
  m'I
madam

Used dyadically, the same verb extends to other useful functionality:

   4|.'not really '
really not 
   1|.mat
I'm  
Adam 
Madam
   1|."1 mat
adamM
'm  I
dam A

Show-and-tell

Advanced topics

[1].

Learning and Teaching J

Materials

Double brackets allow abbreviated (local) links but require a pipe to separate the associated text, like this: Building a GUI in J

  1. Example footnote

the monadic verb +x actually produces the complex conjugate of x.