Hacker News new | past | comments | ask | show | jobs | submit login

Dyalog APL has a safety blanket of procedural programming[1], it's another strange aspect of APL and the internet that it seems almost completely overlooked - unremarked upon and never discussed. e.g. this is roughly a prompt-for-username and validate-username code:

    ∇result←verifyUserName userName

     isValid←1
     message←''

     :If (userName≡'')∨(8<≢userName)
         message←⊂'Please enter a name between 1 and 8 characters long'
         isValid←0
     :ElseIf ' ' ∊ userName
         message←⊂'Please enter a name with no spaces'
         isValid←0
     :EndIf
    ∇result←isValid message



    ∇userName←getUserName
  
      nl←⎕UCS 13 10   ⍝ carriage return, newline
  
      :Repeat
          ⍞←'Enter a username: ',nl
          newName←⍞       ⍝ Read from keyboard input
      
          nameIsValid message←verifyUserName newName
      
          :If 0≡nameIsValid
              ⍞←message
          :EndIf
      
      :Until 1≡nameIsValid
    ∇userName←newName

It's unexciting compared to the dense showoffy codegolf APL which is normally posted on the internet, and what you still don't get with it is things like `string.Length` or `or` or `Console.WriteLine()` etc. That is, procedural/imperative APL looks like APL and doesn't save you from having to know APL symbols or execution model. But it could save you from having to wrangle some weird mathematical dodge around a simple :If/:Else branch or trying to use ⍣ when you really just want to write :For i :In 2 4 6 8 10

It has an OOP/Class system as well, but that doesn't save you from having to know APL either.

[1] I don't think NARS2000 does, and I'm not sure about the bigger IBM / Sharp APLs. I don't think J or K have.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: