### One-based indexing

From a discussion on the Julia website "What’s the big deal? 0 vs 1 based indexing" comes a simple explaination:

```Steven_Sagaert Dec 2016

That’s exactly it.
1-based indexing is actual indexing like in mathematics,
while 0-based “indexing” isn’t indexing at all but pointer arithmetic.
This comes from C where an array is just syntactic sugar for a pointer.
```

One-based, emphasis on indexing, simplifies the creation and use of string and sequence values. The advantages are significant:

• the first item is the one'th item
• length n is equal to the last index n
• the zero'th item is an obvious indexing error
• symmetical reverse indexing using just negative values
• 0'th location is a virtual head
• n+1'th location is a virtual tail

Tutorials for zero-offset languages require diagrams to understand how indexing works. The term "zero-based indexing" is a misnomer; one-based indexing is intuitive

```   string   txt = "hello"
sequence dta = { 1, 2, "cat", {20,2} }

--  1  2    3      4
--- 4 -3   -2     -1

? txt[-1] --> 'o'
? txt[3..4] --> "lo"
? s[3..4]   --> {"cat",{20,2.2}}
```

### Generic operators

Operators are generic:

```-- the + operator always adds

atom chr = 'T'
? chr + 32 --> 't'

atom x = 100
? x + 32  --> 132

```

Operators can span strings and sequences:

```string txt = "HELLO"
? sq_add( txt, 32 ) --> "hello"

sequence dta = { 2, 9, 34 }
? sq_mul( dta, 100 ) -->
```

### Generic routines

```string   txt = "phixprogramming"
sequence dta = {{"fish",0}, {"cat",2} , {"dog",4}  }

? sort(txt) --> "agghiimmnopprrx"
? sort(dta) --> {{"cat",2},{"dog",4},{"fish",0}}

? reverse(txt) --> "gnimmargorpxihp"
? reverse(dta) --> {{"dog",4},{"cat",2},{"fish",0}}

? shuffle(txt) --> "pniipgxomhagrrm"
? shuffle(dta) --> {{"cat",2},{"fish",0},{"dog",4}}

? max(txt)     --> 'x'
? max(dta)     --> {"fish",0}
```

### Equivalence of strings and sequences

Each character is represented by a number value. That is why Phix is generic: operators and routines work the same for all numbers:

```
? sq_sqrt( "Hello" )
--> {8.485281374,10.04987562,10.39230485,10.39230485,10.53565375}

? sq_sqrt( {'H','e','l','l','o'} )
--> {8.485281374,10.04987562,10.39230485,10.39230485,10.53565375}

? sq_sqrt( {72, 101, 108, 108,111 } )
--> {8.485281374,10.04987562,10.39230485,10.39230485,10.53565375}

```

When programming in Phix you learn to recognize similarities between data values and structures.

```_tom

Vin Diesel, The Chronicles of Riddick: Keep What You Kill (2004)

Phix, "Keep What You Learn."

Wikipedia needs a bit of  humour.

Actually, valid educational psychology. Fits in with cognitive load, educational design, magic number 7, and more...

```

The Phix design is "keep what you learn." Learn one aspect of Phix syntax and you can apply it to all cases. Phix means you can practice with strings and apply the same skills to any arbitary data.

```_tom
I'll like to sneak this in once the wiki article is appoved...
```

### Debugging features

Source code safety is ensured by:

• data type checking
• enforcing subscript bounds
• variables must be declared and explicitly assigned values
• argument are passing by-value (but with the efficiency of copy-on-write)
• no pointers

The Phix developer is provided with:

• automatic memory management
• garbage collection
• interpretation and compilation of source code
• gui libraries based on IUP and GTK
• a standard library that includes features like: ipc, json, curl, zip, gmp, regular expressions, sockets, and unit testing
• debugger and execution profiler
• execution tracing

## Rosetta Code

Phix does not directly support: lambda expressions, closures, nested functions, currying, partial function application, function composition, function prototyping, monads, generators, anonymouse recursion, the Y combinator, aspect oriented programming, interfaces, delegates, first class environments, implicit type conversion (of the destructive kind), interactive programming, inverted syntax, list comprehensions, metaprogramming, operator-function-builtin overloading, pointers (other than to raw allocated memory), topic variables, enforced singletons, safe mode, s-expressions, or formal proof construction.

The Rosetta website has over one thousand programming challenges, and states "...we do not (and cannot) have solutions to every task in every language."

Phix has over one thousand completed Rosetta examples. A compact language like Phix is not limited by its simple nature.

```_tom

how many Rosetta tasks have you actually finished?

there are too many for me to count

```

## Execution modes

Interpreter Compiler