« first day (958 days earlier)      last day (1697 days later) » 

12:49 AM
⎕←{⍴0↓⍵}¨(4 4⍴⍳9) (⍳9) (1)
 
@JimmyGauvin
┌───┬─┬─┐
│4 4│9│1│
└───┴─┴─┘
 
 
5 hours later…
5:27 AM
@JimmyGauvin Nice one. Yes, that works too. Short left arguments to and are a newish feature.
@JimmyGauvin Btw, if you put four or more spaces before ⎕← the text changes to monospace font, and avoids \ working as escape rather than a plain character. You can insert four spaces before (all lines) with Ctrl+K.
 
 
4 hours later…
9:58 AM
I'm starting to think trying to learn J and K at the same time was a bad idea
Cross-contamination of what their natives do XD
 
 
1 hour later…
11:11 AM
As a learning example I decided to try to convert a sprite sheet XML file into a series of C structure definitions but I cna't seem to the load the XML file correctly. I load the file with NGET which says that the [1] is the character vector of the files contents, but when I try to pas sit through []XML I keep getting an error I don't understand

file ← ⎕NGET 'test.xml'
file[1]
<TextureAtlas imagePath="sheet.png"><SubTexture name="beam0.png" x="143" y="377

" width="43" height="31"/><SubTexture name="beam1.png" x="327" y="644" wid
 
I am really liking the Arithmetic book with J. Might stick with J for a while
 
 
1 hour later…
12:44 PM
Did some digging around here and found 'Disclose' thanks to other examples.
 
1:28 PM
Here is my workspace session that shows the problem but I don't yet understand why the problem arise (operator error / pebcak obvz but...) could somebody tell me why...

filename ← 'test.xml'
fileinfo ← ⎕NGET filename
fileinfo
<TextureAtlas imagePath="sheet.png"><SubTexture name="beam0.png" x="143" y="377" width="43" height="31"/><Sub

Texture name="beam1.png" x="327" y="644" width="40" height="20"/></TextureAtlas>
UTF-8-NOBOM 10
fileinfo[1]
<TextureAtlas imagePath="sheet.png"><SubTexture name="beam0.png" x="143" y="377" width="43" height="31"/><Sub
 
2:12 PM
@Nathan on the big screen in Elsinore!
 
@EmacsTheViking ⎕NGET returns a three-element vector. Only the first element has the XML data you want (the other two are encoding and line-break-type), so you need ⊃⎕NGET.
@EmacsTheViking Also, welcome to the APL Orchard. If you post multiple messages in quick succession, they will be merged visually. Then you can hit Ctrl+K before posting code. This will insert four spaces before each line, causing the display to use monospace font, avoid escapes, and preserve whitespace.
 
Thanks for the welcome Adam. I'll try to remember all this...I have used the disclose operator now but I can't see the difference between that and just referring to x[1] where x is what was returned from the NGET
surely they are the same thing ?
 
@EmacsTheViking No. indexing with [1] or 1⌷ leaves the element as a neatly packaged scalar. so-to-say "open" up that enclosure to reveal its contents.
⎕←'abc' 'def'[1] ⋄ ⎕←1⌷'abc' 'def' ⋄ ⎕←1⊃'abc' 'def'
 
@Adám
┌───┐
│abc│
└───┘
┌───┐
│abc│
└───┘
abc
 
2:27 PM
aha! Thank you Adam. It seems I have to learn to stop thinking like a conventional coder, I use Elixir and Java mostly and they all start from zero!

This is great information...my total APL exposure time is proably less than 6 hours so far but I think I am hooked.
 
@EmacsTheViking Cool. I'll be very happy to assist you in any way possible. I'm a bit busy this week, but if you ping me, I will get back to you.
(btw, pinging is done by including @ in your message right before a user name)
@EmacsTheViking Have you had a look at our lessons?
 
Thanks for that. If I get truly stuck I'll take you up on that. I first came across APL many years ago. I have been a developer for 36 years now. Switched to functional style over a decade ago...and now I find myself falling for APL....could take me into retirement but with something this absorbing how could you ever want to retire? :)
Yeah, pinging is the norm. i use slack all the time all of the day!
Look at the lessons! Nice link.
Aha! Eureaka moment from the tutorial PDF...the salaries/rates thing I did yesterday showed acessing an array with an array, and it returned...an array!
I think I get it and understand my error now. Brilliant!! Thanks
 
2:52 PM
I think
numbers ← 1 2 3
⊃numbers
1
is that a scalr or a one element array ? how can I tell
it should be a scalar..and is I used ]display on it....I thought I understood but now I think I know I don't anymore! LOL :)
I can quite plainly see that data[1] and ⊃data are not the same whic is the **cause** of my problem using ⎕XML but I am still not grasping the difference. Sorry if I appear dumb at this point....

data ←⎕NGET'test.xml'
data
<TextureAtlas imagePath="sheet.png"><SubTexture name="beam0.png" x="143" y="377" w

idth="43" height="31"/><SubTexture name="beam1.png" x="327" y="644" width="40

" height="20"/></TextureAtlas>
UTF-8-NOBOM 10
xml1←⊃data
xml2←data[1]


]display xml1
┌→─────────────────────────────────────────────────────────────────────────────────
 
Try ≢⍴⊃numbers to see that you have, indeed, extracted a scalar (with empty shape) from numbers.
 
3:14 PM
so IIRC from the rank/depth notes, the 1 means a scalar as in '1 dimension' ? Well, I'll keep at it even though it's still not clear yet! HAHA And I thought learning Haskell had been awkward at times.
 
A scalar is dimension-less and has rank 0. Vectors have rank 1.
≢⍴42 → 0
(I too love Haskell, by the way ;-).
 
@EmacsTheViking In addition to what @TorstenGrust wrote: You can use ⎕SE.Dyalog.Utils.repObj to generate an APL expression equivalent to a given array. A scalar would be 1 vs a vector being ,1. Also, for many values, you can use 1∘⎕JSON to generate the equivalent JSON. A scalar would be 1 vs a vector being [1].
 
sigh.....lmao
so "disclose" is kind of popping something out of the container and showing its true form rather than the container form
I love the overwhelming confusion when learning new things because the payback is the satisfaction when you finally get it! :)
 
3:31 PM
@EmacsTheViking Yes, when used like this. Technically, it is called First as it returns the content of the first element of its argument. That is, if the argument isn't enclosed, it returns the top-left element:
⎕←⊃⎕←3 4⍴⍳12
 
@Adám
1  2  3  4
5  6  7  8
9 10 11 12
1
 
I have "Lesson 7" bookmarked for this evening. I am sure it will make sense sooner or later :) Thanks eveyrbody for your patience!
 
3:46 PM
@EmacsTheViking No problem. Also, the chat bot's profile page has lots of good links.
 
 
1 hour later…
ngn
4:50 PM
@Sherlock9 apl vs j vs k :)
5
 
 
1 hour later…
6:02 PM
@ngn That's so true!
 
ngn
@Adám :)
 

« first day (958 days earlier)      last day (1697 days later) »