use ntheory qw/divisor_sum/;

sub aliquot {
  my($n, $maxterms, $maxn) = @_;
  $maxterms = 16 unless defined $maxterms;
  $maxn = 2**47 unless defined $maxn;

  my %terms = ($n => 1);
  my @allterms = ($n);
  for my $term (2 .. $maxterms) {
    $n = divisor_sum($n)-$n;
    # push onto allterms here if we want the cyclic term to display
    last if $n > $maxn;
    return ("terminates",@allterms, 0) if $n == 0;
    if (defined $terms{$n}) {
      return ("perfect",@allterms)  if $term == 2 && $terms{$n} == 1;
      return ("amicible",@allterms) if $term == 3 && $terms{$n} == 1;
      return ("sociable-".($term-1),@allterms) if $term >  3 && $terms{$n} == 1;
      return ("aspiring",@allterms) if $terms{$n} == $term-1;
      return ("cyclic-".($term-$terms{$n}),@allterms)   if $terms{$n} < $term-1;
    }
    $terms{$n} = $term;
    push @allterms, $n;
  }
  ("non-term",@allterms);
}

for my $n (1..10) {
  my($class, @seq) = aliquot($n);
  printf "%14d %10s [@seq]\n", $n, $class;
}
print "\n";
for my $n (qw/11 12 28 496 220 1184 12496 1264460 790 909 562 1064 1488 15355717786080/) {
  my($class, @seq) = aliquot($n);
  printf "%14d %10s [@seq]\n", $n, $class;
}


import morfa.base;

template <T>
public struct Dynamic
{
    var data: Dict<text, T>;
}

// convenience to create new Dynamic instances
template <T>
public property dynamic(): Dynamic<T>
{
    return Dynamic<T>(new Dict<text,T>());
}

// introduce replacement operator for . - a quoting ` operator
public operator ` { kind = infix, precedence = max, associativity = left, quoting = right }
template <T>
public func `(d: Dynamic<T>, name: text): DynamicElementAccess<T>
{
    return DynamicElementAccess<T>(d, name);
}

// to allow implicit cast from the wrapped instance of T (on access)
template <T>
public func convert(dea: DynamicElementAccess<T>): T
{
    return dea.holder.data[dea.name];
}

// cannot overload assignment - introduce special assignment operator
public operator <- { kind = infix, precedence = assign }
template <T>
public func <-(access: DynamicElementAccess<T>, newEl: T): void
{
    access.holder.data[access.name] = newEl;
}

func main(): void
{
    var test = dynamic<int>;

    test`a <- 10;
    test`b <- 20;
    test`a <- 30;

    println(test`a, test`b);
}

// private helper structure
template <T>
struct DynamicElementAccess
{
    var holder: Dynamic<T>;
    var name: text;

    import morfa.io.format.Formatter;
    public func format(formatt: text, formatter: Formatter): text
    {
        return getFormatFunction(holder.data[name])(formatt, formatter);
    }
}


import json
{.experimental: "dotOperators".}
template `.=`(js: JsonNode, field: untyped, value: untyped) =
  js[astToStr(field)] = %value
template `.`(js: JsonNode, field: untyped): JsonNode = js[astToStr(field)]
var obj = newJObject()
obj.foo = "bar"
echo(obj.foo)
obj.key = 3
echo(obj.key)


#import <Foundation/Foundation.h>
#import <objc/runtime.h>

static void *fooKey = &fooKey; // one way to define a unique key is a pointer variable that points to itself

int main (int argc, const char *argv[]) {
    @autoreleasepool {

        id e = [[NSObject alloc] init];

        // set
        objc_setAssociatedObject(e, fooKey, @1, OBJC_ASSOCIATION_RETAIN);

        // get
        NSNumber *associatedObject = objc_getAssociatedObject(e, fooKey);
        NSLog(@"associatedObject: %@", associatedObject);

    }
    return 0;
}


% Given struct "test"
test.b=1;
test = setfield (test, "c", 3);


d = .dynamicvar~new
d~foo = 123
say d~foo

d2 = .dynamicvar2~new
d~bar = "Fred"
say d~bar

-- a class that allows dynamic variables.  Since this is a mixin, this
-- capability can be added to any class using multiple inheritance
::class dynamicvar MIXINCLASS object
::method init
  expose variables
  variables = .directory~new

-- the UNKNOWN method is invoked for all unknown messages.  We turn this
-- into either an assignment or a retrieval for the desired item
::method unknown
  expose variables
  use strict arg messageName, arguments

  -- assignment messages end with '=', which tells us what to do
  if messageName~right(1) == '=' then do
     variables[messageName~left(messageName~length - 1)] = arguments[1]
  end
  else do
      return variables[messageName]
  end

-- this class is not a direct subclass of dynamicvar, but mixes in the
-- functionality using multiple inheritance
::class dynamicvar2 inherit dynamicvar
::method init
  -- mixin init methods are not automatically invoked, so we must
  -- explicitly invoke this
  self~init:.dynamicvar


>>> import urllib.request
>>> from collections import defaultdict
>>> words = urllib.request.urlopen('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt').read().split()
>>> anagram = defaultdict(list) # map sorted chars to anagrams
>>> for word in words:
	anagram[tuple(sorted(word))].append( word )

>>> count = max(len(ana) for ana in anagram.values())
>>> for ana in anagram.values():
	if len(ana) >= count:
		print ([x.decode() for x in ana])


$CHECKING:OFF
' Warning: Keep the above line commented out until you know your newly edited code works.
'          You can NOT stop a program in mid run (using top right x button) with checkng off.
'
_TITLE "Rosetta Code Anagrams: mod #7 Best times yet w/o memory techniques by bplus 2017-12-12"
' This program now below .4 secs for average time to do 100 loops compared to 92 secs for 1
' loop on my "dinosaur" when I first coded a successful run.
'
' Steve McNeil at QB64.net has +7000 loops per sec on his machine with help of using
' memory techniques.  see page 3 @  http://www.qb64.net/forum/index.php?topic=14622.30
'
' Thanks Steve! I learned allot and am NOW very motivated to learn memory techniques.
'
' This program has timings for 1 loop broken into sections currently commented out and another
' set of timings for multiple loop testing currently set, now at 100 tests for a sort of average.
' But average is misleading, the first test is usually always the longest and really only one test
' is necessary to get the results from a data file that does not change.
'
' Breaking code into logical sections and timing those can help spot trouble areas or the difference
' in a small or great change.
'
' Here is review of speed tips commented as they occur in code:
'
DEFINT A-Z 'there are 25,105 words in the unixdict.txt file so main array index
'           and pointers in sort can all be integers.

' The letters from a word read in from the dictionary file (really just a word list in alpha order)
' are to be counted and coded into an alpha order sequence of letters:
'       eg.  eilv is the same code for words: evil, levi, live, veil, vile
' The longest word in the file had 22 letters, they are all lower case but there are other symbols
' in file like ' and digits we want to filter out.
TYPE wordData
    code AS STRING * 22
    theWord AS STRING * 22
END TYPE
' I originally was coding a word into the whole list (array) of letter counts as a string.
' Then realized I could drop all the zeros if I converted the numbers back to letters.
' I then attached THE word to the end of the coded word using ! to separate the 2 sections.
' That was allot of manipulation with INSTR to find the ! separator and then MID$ to extract the
' code or THE word when I needed the value. All this extra manipulation ended by using TYPE with
' the code part and the word part sharing the same index. Learned from Steve's example!

' Pick the lowest number type needed to cover the problem
DIM SHARED w(25105) AS wordData '  the main array
DIM anagramSetsCount AS _BYTE ' the Rosetta Code Challenge was to find only the largest sets of Anagrams
DIM codeCount AS _BYTE ' counting number of words with same code
DIM wordIndex AS _BYTE
DIM wordLength AS _BYTE
DIM flag AS _BIT 'flag used as true or false
DIM letterCounts(1 TO 26) AS _BYTE 'stores letter counts for coding word
' b$  always stands for building a string.
' For long and strings, I am using the designated suffix

t1# = TIMER: loops = 100
FOR test = 1 TO loops
    'reset these for multiple loop tests
    indexTop = 0 'indexTop for main data array
    anagramSetsCount = 0 'anagrams count if exceed 4 for any one code
    anagramList$ = "" 'list of anagrams

    'get the file data loaded in one pop, disk access is slow!
    OPEN "unixdict.txt" FOR BINARY AS #1
    ' http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
    ' note: when I downloaded this file line breaks were by chr$(10) only.
    ' Steve had coded for either chr$(13) + chr$(10) or just chr$(10)

    fileLength& = LOF(1): buf$ = SPACE$(fileLength&)
    GET #1, , buf$
    CLOSE #1
    ' Getting the data into a big long string saved allot of time as compared to
    ' reading from the file line by line.

    'Process the file data by extracting the word from the long file string and then
    'coding each word of interest, loading up the w() array.
    filePosition& = 1
    WHILE filePosition& < fileLength&
        nextPosition& = INSTR(filePosition&, buf$, CHR$(10))
        wd$ = MID$(buf$, filePosition&, nextPosition& - filePosition&)
        wordLength = LEN(wd$)
        IF wordLength > 2 THEN
            'From Steve's example, changing from REDIM to ERASE saved an amzing amount of time!
            ERASE letterCounts: flag = 0: wordIndex = 1
            WHILE wordIndex <= wordLength
                'From Steve's example, I was not aware of this version of ASC with MID$ built-in
                ansciChar = ASC(wd$, wordIndex) - 96
                IF 0 < ansciChar AND ansciChar < 27 THEN letterCounts(ansciChar) = letterCounts(ansciChar) + 1 ELSE flag = 1: EXIT WHILE
                wordIndex = wordIndex + 1
            WEND
            'don't code and store a word unless all letters, no digits or apostrophes
            IF flag = 0 THEN
                b$ = "": wordIndex = 1
                WHILE wordIndex < 27
                    IF letterCounts(wordIndex) THEN b$ = b$ + STRING$(letterCounts(wordIndex), CHR$(96 + wordIndex))
                    wordIndex = wordIndex + 1
                WEND
                indexTop = indexTop + 1
                w(indexTop).code = b$
                w(indexTop).theWord = wd$
            END IF
        END IF
        IF nextPosition& THEN filePosition& = nextPosition& + 1 ELSE filePosition& = fileLength&
    WEND
    't2# = TIMER
    'PRINT t2# - t1#; " secs to load word array."

    'Sort using a recursive Quick Sort routine on the code key of wordData Type defined.
    QSort 0, indexTop
    't3# = TIMER
    'PRINT t3# - t2#; " secs to sort array."

    'Now find all the anagrams, word permutations, from the same word "code" that we sorted by.
    flag = 0: j = 0
    WHILE j < indexTop
        'Does the sorted code key match the next one on the list?
        IF w(j).code <> w(j + 1).code THEN ' not matched so stop counting and add to report
            IF codeCount > 4 THEN ' only want the largest sets of anagrams 5 or more
                anagramList$ = anagramList$ + b$ + CHR$(10)
                anagramSetsCount = anagramSetsCount + 1
            END IF
            codeCount = 0: b$ = "": flag = 0
        ELSEIF flag THEN ' match and match flag set so just add to count and build set
            b$ = b$ + ", " + RTRIM$(w(j + 1).theWord)
            codeCount = codeCount + 1
        ELSE ' no flag means first match, start counting and building a new set
            b$ = RTRIM$(w(j).theWord) + ", " + RTRIM$(w(j + 1).theWord)
            codeCount = 2: flag = 1
        END IF
        j = j + 1
    WEND
    't4# = TIMER
    'PRINT t4# - t3#; " secs to count matches from array."
NEXT
PRINT "Ave time per loop"; (TIMER - t1#) / loops; " secs, there were"; anagramSetsCount; " anagrams sets of 5 or more words."
PRINT anagramList$

'This sub modified for wordData Type, to sort by the .code key, the w() array is SHARED
SUB QSort (Start, Finish)
    i = Start: j = Finish: x$ = w(INT((i + j) / 2)).code
    WHILE i <= j
        WHILE w(i).code < x$: i = i + 1: WEND
        WHILE w(j).code > x$: j = j - 1: WEND
        IF i <= j THEN
            SWAP w(i), w(j)
            i = i + 1: j = j - 1
        END IF
    WEND
    IF j > Start THEN QSort Start, j
    IF i < Finish THEN QSort i, Finish
END SUB


                                       ' set up the arrays
Push Dup("the"),    Dup("that"),     Dup("a")     : a = FUNC(_Ambsel (0))
Push Dup("frog"),   Dup("elephant"), Dup("thing") : b = FUNC(_Ambsel (a))
Push Dup("walked"), Dup("treaded"),  Dup("grows") : c = FUNC(_Ambsel (b))
Push Dup("slowly"), Dup("quickly")                : f = FUNC(_Ambsel (c))
                                       ' we'll reuse variable f ;-)
Proc _Ambassert (_Connect)             ' now assert the function required

For w = 1 To @(0)                      ' and evaluate..
  For x = a+1 To [email protected](a)
    For y = b+1 To [email protected](b)
      For z = c+1 To [email protected](c)
        If FUNC(_Amb (@(w), @(x))) * FUNC(_Amb (@(x), @(y))) * FUNC(_Amb (@(y), @(z))) Then
          Print Show(@(w)), Show(@(x)), Show(@(y)), Show(@(z))
        EndIf
      Next
    Next
  Next
Next

End

_Ambsel                                ' array setup
  Param (1)
  Local (1)

  @([email protected]) = Used()
  For [email protected] = [email protected]+1 To [email protected] + @([email protected])
    @([email protected]) = Pop ()
  Next
Return ([email protected])

_Amb Param (2) : Return (FUNC(f ([email protected], [email protected])))
_Ambassert Param (1) : f = [email protected] : Return ' set up the function
_Connect Param (2) : Return (Peek ([email protected], Len([email protected])-1) = Peek([email protected], 0))


class ambiguous
	dim sRule

	public property let rule( x )
		sRule = x
	end property

	public default function amb(p1, p2)
		amb = eval(sRule)
	end function
end class


function aliquot(atom n)
sequence s = {n}
integer k
    if n=0 then                             return {"terminating",{0}} end if
    while length(s)<16
      and n<140737488355328 do
        n = sum(factors(n,-1))
        k = find(n,s)
        if k then
            if k=1 then
                if length(s)=1 then         return {"perfect",s}
                elsif length(s)=2 then      return {"amicable",s}
                end if                      return {"sociable",s}
            elsif k=length(s) then          return {"aspiring",s}
            end if                          return {"cyclic",append(s,n)}
        elsif n=0 then                      return {"terminating",s}
        end if
        s = append(s,n)
    end while
                                            return {"non-terminating",s}
end function

constant n = tagset(12)&{28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080}
for i=1 to length(n) do
    {string classification, sequence dseq} = aliquot(n[i])
    dseq = join(apply(true,sprintf,{{"%d"},dseq}),",")
    printf(1,"%14d => %15s, {%s}\n",{n[i],classification,dseq})
end for


'=================
class fleximembers
'=================

indexbase 0
bstring buf, *varl
sys     dp,en

method addVar(string name,dat)
  sys le=len buf
  if dp+16>le then
    buf+=nuls 0x100 : le+=0x100 :
  end if
  @varl=?buf
  varl[en]=name
  varl[en+1]=dat
  dp+=2*sizeof sys
  en+=2 'next slot
end method

method find(string name) as sys
  sys i
  for i=0 to <en step 2
    if name=varl[i] then return i+1
  next
end method

method vars(string name) as string
  sys f=find(name)
  if f then return varl[f]
end method

method VarF(string name) as double
  return vars(name)
end method

method VarI(string name) as sys
  return vars(name)
end method

method vars(string name,dat)
  bstring varl at buf
  sys f=find(name)
  if f then varl[f]=dat
end method

method delete()
  sys i
  sys v at buf
  for i=0 to <en
     freememory v[i]
  next
  freememory ?buf
  ? buf=0 : en=0 : dp=0
end method

end class

'TEST

fleximembers a

a.addVar "p",5
a.addVar "q",4.5
a.addVar "r","123456"

print a.Vars("q")+a.vars("q") 'result 4.54.5
print a.Varf("q")+a.varf("q") 'result 9

a.delete


declare
  %% Creates a new class derived from BaseClass
  %% with an added feature (==public immutable attribute)
  fun {AddFeature BaseClass FeatureName FeatureValue}
     class DerivedClass from BaseClass
        feat
	   %% "FeatureName" is escaped, otherwise a new variable
	   %% refering to a private feature would be created
           !FeatureName:FeatureValue
     end
  in
     DerivedClass
  end

  class Base
     feat
        bar:1

     meth init
        skip
     end
  end

  Derived = {AddFeature Base foo 2}

  Instance = {New Derived init}
in
  {Show Instance.bar} %% inherited feature
  {Show Instance.foo} %% feature of "synthesized" class


package Empty;

# Constructor. Object is hash.
sub new { return bless {}, shift; }

package main;

# Object.
my $o = Empty->new;

# Set runtime variable (key => value).
$o->{'foo'} = 1;


class wobbly dynamic
    -- (pre-define a few fields/methods if you like)
end class
wobbly wobble = new()
?wobble.jelly               -- 0
--?wobble["jelly"]          -- for dynamic names use []
wobble.jelly = "green"
?wobble.jelly               -- "green"


class E {};

$e=new E();

$e->foo=1;

$e->{"foo"} = 1; // using a runtime name
$x = "foo";
$e->$x = 1; // using a runtime name in a variable


  $ "rosetta/unixdict.txt" sharefile drop nest$
  [] swap witheach
    [ dup sort
      nested swap nested join
      nested join ]
  sortwith [ 0 peek swap 0 peek $< ]
  dup
  [ dup [] ' [ [ ] ] rot
    witheach
       [ tuck 0 peek swap 0 peek = if
           [ tuck nested join swap ] ]
    drop
    dup [] != while
    nip again ]
  drop
  witheach
    [ over witheach
        [ 2dup 0 peek swap 0 peek = iff
            [ 1 peek echo$ sp ]
          else drop ]
      drop cr ]
  drop


words <- readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
word_group <- sapply(
    strsplit(words, split=""), # this will split all words to single letters...
    function(x) paste(sort(x), collapse="") # ...which we sort and paste again
)

counts <- tapply(words, word_group, length) # group words by class to get number of anagrams
anagrams <- tapply(words, word_group, paste, collapse=", ") # group to get string with all anagrams

# Results
table(counts)
counts
    1     2     3     4     5
22263  1111   155    31     6

anagrams[counts == max(counts)]
                               abel                               acert
     "abel, able, bale, bela, elba" "caret, carte, cater, crate, trace"
                              aegln                               aeglr
"angel, angle, galen, glean, lange" "alger, glare, lager, large, regal"
                               aeln                                eilv
     "elan, lane, lean, lena, neal"      "evil, levi, live, veil, vile"


var finalRes = []

var amb // recursive closure
amb = Fn.new { |wordsets, res|
    if (wordsets.count == 0) {
        finalRes.addAll(res)
        return true
    }
    var s = ""
    var l = res.count
    if (l > 0) s = res[l-1]
    res.add("")
    for (word in wordsets[0]) {
        res[l] = word
        if (l > 0 && s[-1] != res[l][0]) continue
        if (amb.call(wordsets[1..-1], res.toList)) return true
    }
    return false
}

var wordsets = [
    [ "the", "that", "a" ],
    [ "frog", "elephant", "thing" ],
    [ "walked", "treaded", "grows" ],
    [ "slowly", "quickly" ]
}

if (amb.call(wordsets, [])) {
    System.print(finalRes.join(" "))
} else {
    System.print("No amb found")
}


divisor_sum(N) = R =>
    Total = 1,
    Power = 2,
    % Deal with powers of 2 first
    while (N mod 2 == 0)
        Total := Total + Power,
        Power := Power*2,
        N := N div 2
    end,
    % Odd prime factors up to the square root
    P = 3,
    while (P*P =< N)
        Sum = 1,
        Power1 = P,
        while (N mod P == 0)
            Sum := Sum + Power1,
            Power1 := Power1*P,
            N := N div P
        end,
        Total := Total * Sum,
        P := P+2
    end,
    % If n > 1 then it's prime
    if N > 1 then
        Total := Total*(N + 1)
    end,
    R = Total.

% See https://en.wikipedia.org/wiki/Aliquot_sequence
aliquot_sequence(N,Limit,Seq,Class) =>
    aliquot_sequence(N,Limit,[N],Seq,Class).

aliquot_sequence(_,0,_,Seq,Class) => Seq = [], Class = 'non-terminating'.
aliquot_sequence(_,_,[0|_],Seq,Class) => Seq = [0], Class = terminating.
aliquot_sequence(N,_,[N,N|_],Seq,Class) => Seq = [], Class = perfect.
aliquot_sequence(N,_,[N,_,N|_],Seq,Class) => Seq = [N], Class = amicable.
aliquot_sequence(N,_,[N|S],Seq,Class), membchk(N,S) =>
    Seq = [N], Class = sociable.
aliquot_sequence(_,_,[Term,Term|_],Seq,Class) => Seq = [], Class = aspiring.
aliquot_sequence(_,_,[Term|S],Seq,Class), membchk(Term,S) =>
    Seq = [Term], Class = cyclic.
aliquot_sequence(N,Limit,[Term|S],Seq,Class) =>
    Seq = [Term|Rest],
    Sum = divisor_sum(Term),
    Term1 is Sum - Term,
    aliquot_sequence(N,Limit-1,[Term1,Term|S],Rest,Class).

main =>
    foreach (N in [11,12,28,496,220,1184,12496,1264460,790,909,562,1064,1488,15355717786080,153557177860800])
        aliquot_sequence(N,16,Seq,Class),
        printf("%w: %w, sequence: %w ", N, Class, Seq[1]),
        foreach (I in 2..len(Seq), break(Seq[I] == Seq[I-1]))
            printf("%w ", Seq[I])
        end,
        nl
    end.


function Get-NextAliquot ( [int]$X )
    {
    If ( $X -gt 1 )
        {
        $NextAliquot = 0
        (1..($X/2)).Where{ $x % $_ -eq 0 }.ForEach{ $NextAliquot += $_ }.Where{ $_ }
        return $NextAliquot
        }
    }

function Get-AliquotSequence ( [int]$K, [int]$N )
    {
    $X = $K
    $X
    (1..($N-1)).ForEach{ $X = Get-NextAliquot $X; $X }
    }

function Classify-AlliquotSequence ( [int[]]$Sequence )
    {
    $K = $Sequence[0]
    $LastN = $Sequence.Count
    If ( $Sequence[-1] -eq 0 ) { return "terminating" }
    If ( $Sequence[-1] -eq 1 ) { return "terminating" }
    If ( $Sequence[1] -eq $K ) { return "perfect"     }
    If ( $Sequence[2] -eq $K ) { return "amicable"    }
    If ( $Sequence[3..($Sequence.Count-1)] -contains $K ) { return "sociable" }
    If ( $Sequence[-1] -eq $Sequence[-2] ) { return "aspiring" }
    If ( $Sequence.Count -gt ( $Sequence | Select -Unique ).Count ) { return "cyclic" }
    return "non-terminating and non-repeating through N = $($Sequence.Count)"
    }

(1..10).ForEach{ [string]$_ + " is " + ( Classify-AlliquotSequence -Sequence ( Get-AliquotSequence -K $_ -N 16 ) ) }

( 11, 12, 28, 496, 220, 1184, 790, 909, 562, 1064, 1488 ).ForEach{ [string]$_ + " is " + ( Classify-AlliquotSequence -Sequence ( Get-AliquotSequence -K $_ -N 16 ) ) }


: (setq MyObject (new '(+MyClass)))       # Create some object
-> $385605941
: (put MyObject 'newvar '(some value))    # Set variable
-> (some value)
: (show MyObject)                         # Show the object
$385605941 (+MyClass)
   newvar (some value)
-> $385605941


class CSV
{
    mapping variables = ([]);

    mixed `->(string name)
    {
        return variables[name];
    }

    void `->=(string name, mixed value)
    {
        variables[name] = value;
    }

    array _indices()
    {
        return indices(variables);
    }
}

object csv = CSV();
csv->greeting = "hello world";
csv->count = 1;
csv->lang = "Pike";

indices(csv);
Result: ({ /* 3 elements */
              "lang",
              "count",
              "greeting"
         })


lib objectclass;

define :class foo;
enddefine;

define define_named_method(method, class);
    lvars method_str = method >< '';
    lvars class_str = class >< '';
    lvars method_hash_str = 'hash_' >< length(class_str) >< '_'
                              >< class_str >< '_' >< length(method_str)
                              >< '_' >< method_str;
    lvars method_hash = consword(method_hash_str);
    pop11_compile([
        lvars ^method_hash = newassoc([]);
        define :method ^method(self : ^class);
            ^method_hash(self);
        enddefine;
        define :method updaterof ^method(val, self : ^class);
            val -> ^method_hash(self);
        enddefine;
    ]);
enddefine;

define_named_method("met1", "foo");
lvars bar = consfoo();
met1(bar) =>  ;;; default value -- false
"baz" -> met1(bar);
met1(bar) =>  ;;; new value


$x = 42 `
     | Add-Member -PassThru `
        NoteProperty `
        Title `
        "The answer to the question about life, the universe and everything"


class empty(object):
    pass
e = empty()


class Bar { }             # an empty class

my $object = Bar.new;     # new instance

role a_role {             # role to add a variable: foo,
   has $.foo is rw = 2;   # with an initial value of 2
}

$object does a_role;      # compose in the role

say $object.foo;          # prints: 2
$object.foo = 5;          # change the variable
say $object.foo;          # prints: 5

my $ohno = Bar.new;       # new Bar object
#say $ohno.foo;           # runtime error, base Bar class doesn't have the variable foo

my $this = $object.new;   # instantiate a new Bar derived from $object
say $this.foo;            # prints: 2 - original role value

my $that = $object.clone; # instantiate a new Bar derived from $object copying any variables
say $that.foo;            # 5 - value from the cloned object


         LA    R3,I                load address of I
...
I        DS    F


#lang racket

(require net/url)

(define (get-lines url-string)
  (define port (get-pure-port (string->url url-string)))
  (for/list ([l (in-lines port)]) l))

(define (hash-words words)
  (for/fold ([ws-hash (hash)]) ([w words])
    (hash-update ws-hash
                 (list->string (sort (string->list w) < #:key (λ (c) (char->integer c))))
                 (λ (ws) (cons w ws))
                 (λ () '()))))

(define (get-maxes h)
  (define max-ws (apply max (map length (hash-values h))))
  (define max-keys (filter (λ (k) (= (length (hash-ref h k)) max-ws)) (hash-keys h)))
  (map (λ (k) (hash-ref h k)) max-keys))

(get-maxes (hash-words (get-lines "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")))


my @anagrams = 'unixdict.txt'.IO.words.classify(*.comb.sort.join).values;

my $max = @anagrams».elems.max;

.put for @anagrams.grep(*.elems == $max);


sub wordsOK(string1$, string2$)
    return right$(string1$, 1) == left$(string2$, 1)
End sub

sub Amb$(A$(), B$(), C$(), D$())
    local a2, b2, c2, d2

    For a2 = 1 To arraysize(A$(), 1)
        For b2 = 1 To arraysize(B$(), 1)
            For c2 = 1 To arraysize(C$(), 1)
                For d2 = 1 To arraysize(D$(), 1)
                    If wordsOK(A$(a2), B$(b2)) And wordsOK(B$(b2), C$(c2)) And wordsOK(C$(c2), D$(d2)) Then
                        Return A$(a2) + " " + B$(b2) + " " + C$(c2) + " " + D$(d2)
                    End If
                Next
            Next
        Next
    Next
    Return ""
End sub

Dim set1$(1), set2$(1), set3$(1), set4$(1)

void = token("the that a", set1$())
void = token("frog elephant thing", set2$())
void = token("walked treaded grows", set3$())
void = token("slowly quickly", set4$())

result$ = Amb$(set1$(), set2$(), set3$(), set4$())

If result$ <> "" Then
    Print "Correct sentence would be: ", result$
Else
    Print "Failed to fine a correct sentence."
End If


fcn joins(a,b){ a[-1]==b[0] }  // the constraint


% See https://en.wikipedia.org/wiki/Divisor_function
divisor_sum(N, Total):-
    divisor_sum_prime(N, 2, 2, Total1, 1, N1),
    divisor_sum(N1, 3, Total, Total1).

divisor_sum(1, _, Total, Total):-
    !.
divisor_sum(N, Prime, Total, Running_total):-
    Prime * Prime =< N,
    !,
    divisor_sum_prime(N, Prime, Prime, P, 1, M),
    Next_prime is Prime + 2,
    Running_total1 is P * Running_total,
    divisor_sum(M, Next_prime, Total, Running_total1).
divisor_sum(N, _, Total, Running_total):-
    Total is (N + 1) * Running_total.

divisor_sum_prime(N, Prime, Power, Total, Running_total, M):-
    0 is N mod Prime,
    !,
    Running_total1 is Running_total + Power,
    Power1 is Power * Prime,
    N1 is N // Prime,
    divisor_sum_prime(N1, Prime, Power1, Total, Running_total1, M).
divisor_sum_prime(N, _, _, Total, Total, N).

% See https://en.wikipedia.org/wiki/Aliquot_sequence
aliquot_sequence(N, Limit, Sequence, Class):-
    aliquot_sequence(N, Limit, [N], Sequence, Class).

aliquot_sequence(_, 0, _, [], 'non-terminating'):-!.
aliquot_sequence(_, _, [0|_], [0], terminating):-!.
aliquot_sequence(N, _, [N, N|_], [], perfect):-!.
aliquot_sequence(N, _, [N, _, N|_], [N], amicable):-!.
aliquot_sequence(N, _, [N|S], [N], sociable):-
    memberchk(N, S),
    !.
aliquot_sequence(_, _, [Term, Term|_], [], aspiring):-!.
aliquot_sequence(_, _, [Term|S], [Term], cyclic):-
    memberchk(Term, S),
    !.
aliquot_sequence(N, Limit, [Term|S], [Term|Rest], Class):-
    divisor_sum(Term, Sum),
    Term1 is Sum - Term,
    L1 is Limit - 1,
    aliquot_sequence(N, L1, [Term1, Term|S], Rest, Class).

write_aliquot_sequence(N, Sequence, Class):-
    writef('%w: %w, sequence:', [N, Class]),
    write_aliquot_sequence(Sequence).

write_aliquot_sequence([]):-
    nl,
    !.
write_aliquot_sequence([Term|Rest]):-
    writef(' %w', [Term]),
    write_aliquot_sequence(Rest).

main:-
    between(1, 10, N),
    aliquot_sequence(N, 16, Sequence, Class),
    write_aliquot_sequence(N, Sequence, Class),
    fail.
main:-
    member(N, [11, 12, 28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488]),
    aliquot_sequence(N, 16, Sequence, Class),
    write_aliquot_sequence(N, Sequence, Class),
    fail.
main.


rebol [
	Title: "Add Variables to Class at Runtime"
	URL: http://rosettacode.org/wiki/Adding_variables_to_a_class_instance_at_runtime
]

; As I understand it, a REBOL object can only ever have whatever
; properties it was born with. However, this is somewhat offset by the
; fact that every instance can serve as a prototype for a new object
; that also has the new parameter you want to add.

; Here I create an empty instance of the base object (x), then add the
; new instance variable while creating a new object prototyped from
; x. I assign the new object to x, et voila', a dynamically added
; variable.

x: make object! [] ; Empty object.

x: make x [
	newvar: "forty-two" ; New property.
]

print "Empty object modifed with 'newvar' property:"
probe x

; A slightly more interesting example:

starfighter: make object! [
	model: "unknown"
	pilot: none
]
x-wing: make starfighter [
	model: "Incom T-65 X-wing"
]

squadron: reduce [
	make x-wing [pilot: "Luke Skywalker"]
	make x-wing [pilot: "Wedge Antilles"]
	make starfighter [
		model: "Slayn & Korpil B-wing"
		pilot: "General Salm"
	]
]

; Adding new property here.
squadron/1: make squadron/1 [deathstar-removal-expert: yes]

print [crlf "Fighter squadron:"]
foreach pilot squadron [probe pilot]


person: make object! [
  name: none
  age:  none
]

people: reduce [make person [name: "fred" age: 20] make person [name: "paul" age: 21]]
people/1: make people/1 [skill: "fishing"]

foreach person people [
  print reduce [person/age "year old" person/name "is good at" any [select person 'skill "nothing"]]
]


o1 = new point
addattribute(o1,"x")
addattribute(o1,"y")
addattribute(o1,"z")
see o1 {x=10 y=20 z=30}
class point


class Empty
end

e = Empty.new
class << e
  attr_accessor :foo
end
e.foo = 1
puts e.foo  # output: "1"

f = Empty.new
f.foo = 1   # raises NoMethodError


import language.dynamics
import scala.collection.mutable.HashMap

class A extends Dynamic {
  private val map = new HashMap[String, Any]
  def selectDynamic(name: String): Any = {
    return map(name)
  }
  def updateDynamic(name:String)(value: Any) = {
    map(name) = value
  }
}


class Empty{};
var e = Empty();    # create a new class instance
e{:foo} = 42;       # add variable 'foo'
say e{:foo};        # print the value of 'foo'


;;;;;;; zero page RAM memory addresses
CursorX equ $00
CursorY equ $01
temp    equ $02
;;;;;;; memory-mapped hardware registers
BorderColor equ $D020

Joystick1   equ $DC01
Joystick2   equ $DC00


UserRam equ $100000
Cursor_X equ UserRam           ;$100000, byte length
Cursor_Y equ UserRam+1         ;$100001, byte length
SixteenBitData equ UserRam+2   ;$100002, word length (VASM doesn't allow labels to begin with numbers.)
ThirtyTwoBitData equ UserRam+4 ;$100004, long length

;GET THE ADDRESS

LEA ThirtyTwoBitData,A0        ;load $100004 into A0.


.model small
.stack 1024
.data
UserRam 256 DUP (0) ;define the next 256 bytes as user RAM, initialize them all to zero.

.code

mov ax, seg UserRam         ;load into AX the segment where UserRam is stored.
mov es, ax                  ;load that value into the Extra Segment register

mov ax, offset UserRam      ;load into AX the address of UserRam
mov di, ax                  ;load that value into the destination index register


/* ARM assembly AArch64 Raspberry PI 3B */
/*  program adrvar.s   */
/*************************************/
/* Constantes                        */
/*************************************/
.equ STDOUT, 1
.equ WRITE,  64
.equ EXIT,   93
/*************************************/
/* Initialized data                  */
/*************************************/
.data
szMessage:      .asciz "Hello. \n"       // message
szRetourLigne:  .asciz "\n"
qValDeb:        .quad 5                   // value 5 in array of 8 bytes
/*************************************/
/* No Initialized data               */
/*************************************/
.bss
qValeur:  .skip  8                       // reserve 8 bytes in memory
/*************************************/
/* Program code                      */
/*************************************/
.text
.global main
main:
    ldr x0,=szMessage                    // adresse of message short program
    bl affichageMess                     // call function
                                         //  or
    ldr x0,qAdrszMessage                 // adresse of message big program (size code > 4K)
    bl affichageMess                     // call function

    ldr x1,=qValDeb                      // adresse of variable -> x1  short program
    ldr x0,[x1]                          // value of iValdeb  -> x0
    ldr x1,qAdriValDeb                   // adresse of variable -> x1  big program
    ldr x0,[x1]                          // value of iValdeb  -> x0

    /* set variables  */
    ldr x1,=qValeur                      // adresse of variable -> x1  short program
    str x0,[x1]                          // value of x0 ->  iValeur
    ldr x1,qAdriValeur                   // adresse of variable -> x1  big program
    str x0,[x1]                          // value of x0 ->  iValeur

 /* end of  program */
    mov x0,0                             // return code
    mov x8,EXIT                          // request to exit program
    svc 0                                // perform the system call
qAdriValDeb:            .quad qValDeb
qAdriValeur:            .quad qValeur
qAdrszMessage:          .quad szMessage
qAdrszRetourLigne:      .quad szRetourLigne
/******************************************************************/
/*     String display with  size compute                          */
/******************************************************************/
/* x0 contains string address (string ended with zero binary) */
affichageMess:
    stp x0,x1,[sp,-16]!        // save  registers
    stp x2,x8,[sp,-16]!        // save  registers
    mov x2,0                   // size counter
1:                             // loop start
    ldrb w1,[x0,x2]            // load a byte
    cbz w1,2f                  // if zero -> end string
    add x2,x2,#1               // else increment counter
    b 1b                       // and loop
2:                             // x2 =  string size
    mov x1,x0                  // string address
    mov x0,STDOUT              // output Linux standard
    mov x8,WRITE               // code call system "write"
    svc 0                      // call systeme Linux
    ldp x2,x8,[sp],16          // restaur  2 registres
    ldp x0,x1,[sp],16          // restaur  2 registres
    ret                        // retour adresse lr x30


F is_prime(a)
   I a == 2
      R 1B
   I a < 2 | a % 2 == 0
      R 0B
   L(i) (3 .. Int(sqrt(a))).step(2)
      I a % i == 0
         R 0B
   R 1B

F digit_sum(=n)
   V sum = 0
   L n > 0
      sum += n % 10
      n I/= 10
   R sum

V additive_primes = 0
L(i) 2..499
   I is_prime(i) & is_prime(digit_sum(i))
      additive_primes++
      print(i, end' ‘ ’)
print("\nFound "additive_primes‘ additive primes less than 500’)


dim x as integer, y as integer
dim SortX as integer
dim StrOutPut as string
dim Count as integer
dim MaxCount as integer

dim AnaList as QStringlist
dim wordlist as QStringlist
dim Templist as QStringlist
dim Charlist as Qstringlist

function sortChars(expr as string) as string
    Charlist.clear
    for SortX = 1 to len(expr)
         Charlist.AddItems expr[SortX]
    next
    charlist.sort
    result = Charlist.text - chr$(10) - chr$(13)
end function

'--- Start main code
    wordlist.loadfromfile ("unixdict.txt")

    'create anagram list
    for x = 0 to wordlist.itemcount-1
        AnaList.AddItems sortChars(wordlist.item(x))
    next

    'Filter largest anagram lists
    analist.sort
    MaxCount = 0

    for x = 0 to AnaList.Itemcount-1
        Count = 0
        for y = x+1 to AnaList.Itemcount-1
            if AnaList.item(y) = AnaList.item(x) then
                inc(count)
            else
                if count > MaxCount then
                    Templist.clear
                    MaxCount = Count
                    Templist.AddItems AnaList.item(x)
                elseif count = MaxCount then
                    Templist.AddItems AnaList.item(x)
                end if
                exit for
            end if
        next
    next

    'Now get the words
    for x = 0 to Templist.Itemcount-1
        for y = 0 to wordlist.Itemcount-1
            if Templist.item(x) = sortChars(wordlist.item(y)) then
                StrOutPut = StrOutPut + wordlist.item(y) + "  "
            end if
        next
        StrOutPut = StrOutPut + chr$(13) + chr$(10)
    next

ShowMessage StrOutPut
End


import Prelude;

list[str] OrderedRep(str word){
	return sort([word[i] | i <- [0..size(word)-1]]);
}
public list[set[str]] anagram(){
	allwords = readFileLines(|http://wiki.puzzlers.org/pub/wordlists/unixdict.txt|);
	AnagramMap = invert((word : OrderedRep(word) | word <- allwords));
	longest = max([size(group) | group <- range(AnagramMap)]);
	return [AnagramMap[rep]| rep <- AnagramMap, size(AnagramMap[rep]) == longest];
}


from proper_divisors import proper_divs
from functools import lru_cache

@lru_cache()
def pdsum(n):
    return sum(proper_divs(n))

def aliquot(n, maxlen=16, maxterm=2**47):
    if n == 0:
        return 'terminating', [0]
    s, slen, new = [n], 1, n
    while slen <= maxlen and new < maxterm:
        new = pdsum(s[-1])
        if new in s:
            if s[0] == new:
                if slen == 1:
                    return 'perfect', s
                elif slen == 2:
                    return 'amicable', s
                else:
                    return 'sociable of length %i' % slen, s
            elif s[-1] == new:
                return 'aspiring', s
            else:
                return 'cyclic back to %i' % new, s
        elif new == 0:
            return 'terminating', s + [0]
        else:
            s.append(new)
            slen += 1
    else:
        return 'non-terminating', s

if __name__ == '__main__':
    for n in range(1, 11):
        print('%s: %r' % aliquot(n))
    print()
    for n in [11, 12, 28, 496, 220, 1184,  12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080]:
        print('%s: %r' % aliquot(n))


define: #Empty -> Cloneable clone.
define: #e -> Empty clone.
e addSlotNamed: #foo valued: 1.


|addSlot p|

addSlot :=
  [:obj :slotName |
    |anonCls newObj|
    anonCls := obj class
            subclass:(obj class name,'+') asSymbol
            instanceVariableNames:slotName
            classVariableNames:''
            poolDictionaries:'' category:nil
            inEnvironment:nil.
    anonCls compile:('%1 ^  %1' bindWith:slotName).
    anonCls compile:('%1:v %1 := v' bindWith:slotName).
    newObj := anonCls cloneFrom:obj.
    obj become:newObj.
  ].


import Foundation

let fooKey = UnsafeMutablePointer<UInt8>.alloc(1)

class MyClass { }
let e = MyClass()

// set
objc_setAssociatedObject(e, fooKey, 1, .OBJC_ASSOCIATION_RETAIN)

// get
if let associatedObject = objc_getAssociatedObject(e, fooKey) {
  print("associated object: \(associatedObject)")
} else {
  print("no associated object")
}


% package require TclOO
% oo::class create summation {
   constructor {} {
       variable v 0
   }
   method add x {
       variable v
       incr v $x
   }
   method value {{var v}} {
       variable $var
       return [set $var]
   }
   destructor {
       variable v
       puts "Ended with value $v"
   }
}
::summation
% set s [summation new]
% # Do the monkey patch!
% set [info object namespace $s]::time now
now
% # Prove it's really part of the object...
% $s value time
now
%


import "io" for Stdin, Stdout

class Birds {
    construct new(userFields) {
        _userFields = userFields
    }
    userFields { _userFields }
}

var userFields = {}
System.print("Enter three fields to add to the Birds class:")
for (i in 0..2) {
    System.write("\n  name : ")
    Stdout.flush()
    var name = Stdin.readLine()
    System.write("  value: ")
    Stdout.flush()
    var value = Num.fromString(Stdin.readLine())
    userFields[name] = value
}

var birds = Birds.new(userFields)

System.print("\nYour fields are:\n")
for (kv in birds.userFields) {
    System.print("  %(kv.key) = %(kv.value)")
}


PROC Main()
  BYTE v=[123]

  PrintF("Value of variable: %B%E",v)
  PrintF("Address of variable: %H%E",@v)
RETURN


The_Address : System.Address;
I : Integer;
The_Address := I'Address;


[4]INT test := (222,444,666,888);
REF INT reference := test[3];
REF INT(reference) := reference + 111;
print(("test value is now: ",test))


use std, array		(: array.arg also defines pointer operators :)
let var = 42
let ptr = &var		(: value of ptr is address of var :)
print var		(: prints 42 :)
(*ptr)++		(: increments value pointed by ptr :)
print var		(: prints 43 :)


/* ARM assembly Raspberry PI  */
/*  program adrvar.s   */

/* Constantes    */
.equ STDOUT, 1
.equ WRITE,  4
.equ EXIT,   1
/* Initialized data */
.data
szMessage:      .asciz "Hello. \n "       @ message
szRetourLigne:  .asciz "\n"
iValDeb:        .int 5      @ value 5 in array of 4 bytes
/* No Initialized data */
.bss
iValeur:     .skip  4     @ reserve 4 bytes in memory

.text
.global main
main:
        ldr r0,=szMessage          @ adresse of message  short program
	bl affichageMess            @ call function
	                                @  or
	ldr r0,iAdrszMessage         @ adresse of message big program (size code > 4K)
        bl affichageMess            @ call function

	ldr r1,=iValDeb              @ adresse of variable -> r1  short program
	ldr r0,[r1]                    @ value of iValdeb  -> r0
	ldr r1,iAdriValDeb           @ adresse of variable -> r1  big program
	ldr r0,[r1]                    @ value of iValdeb  -> r0

	/* set variables  */
	ldr r1,=iValeur               @ adresse of variable -> r1  short program
	str r0,[r1]                     @ value of r0 ->  iValeur
	ldr r1,iAdriValeur           @ adresse of variable -> r1  big program
	str r0,[r1]                     @ value of r0 ->  iValeur

 /* end of  program */
    mov r0, #0                  @ return code
    mov r7, #EXIT              @ request to exit program
    swi 0                       @ perform the system call
iAdriValDeb:  .int iValDeb
iAdriValeur:  .int iValeur
iAdrszMessage: .int szMessage
iAdrszRetourLigne: .int szRetourLigne
/******************************************************************/
/*     affichage des messages   avec calcul longueur              */
/******************************************************************/
/* r0 contient l adresse du message */
affichageMess:
	push {fp,lr}    /* save des  2 registres */
	push {r0,r1,r2,r7}    /* save des autres registres */
	mov r2,#0   /* compteur longueur */
1:	      /*calcul de la longueur */
    ldrb r1,[r0,r2]  /* recup octet position debut + indice */
	cmp r1,#0       /* si 0 c est fini */
	beq 1f
	add r2,r2,#1   /* sinon on ajoute 1 */
	b 1b
1:	/* donc ici r2 contient la longueur du message */
	mov r1,r0        /* adresse du message en r1 */
	mov r0,#STDOUT      /* code pour écrire sur la sortie standard Linux */
    mov r7, #WRITE                  /* code de l appel systeme 'write' */
    swi #0                      /* appel systeme */
	pop {r0,r1,r2,r7}     /* restaur des autres registres */
	pop {fp,lr}    /* restaur des  2 registres */
    bx lr	        /* retour procedure */


/* ARM assembly AARCH64 Raspberry PI 3B or android 64 bits */
/*  program additivePrime64.s   */

/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"

.equ MAXI,      500

/*********************************/
/* Initialized data              */
/*********************************/
.data
szMessResult:       .asciz "Prime  : @ \n"
szMessCounter:      .asciz "Number found : @ \n"
szCarriageReturn:   .asciz "\n"

/*********************************/
/* UnInitialized data            */
/*********************************/
.bss
sZoneConv:                  .skip 24
TablePrime:                 .skip 8 * MAXI
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main
main:                               // entry of program

    bl createArrayPrime
    mov x5,x0                       // prime number

    ldr x4,qAdrTablePrime           // address prime table
    mov x10,#0                      // init counter
    mov x6,#0                       // indice
1:
    ldr x2,[x4,x6,lsl #3]           // load prime
    mov x9,x2                       // save prime
    mov x7,#0                       // init digit sum
    mov x1,#10                      // divisor
2:                                  // begin loop
    mov x0,x2                       // dividende
    udiv x2,x0,x1
    msub x3,x2,x1,x0                // compute remainder
    add x7,x7,x3                    // add digit to digit sum
    cmp x2,#0                       // quotient null ?
    bne 2b                          // no -> comppute other digit

    mov x8,#1                       // indice
4:                                  // prime search loop
    cmp x8,x5                       // maxi ?
    bge 5f                          // yes
    ldr x0,[x4,x8,lsl #3]           // load prime
    cmp x0,x7                       // prime >= digit sum ?
    add x0,x8,1
    csel x8,x0,x8,lt                // no -> increment indice
    blt 4b                          // and loop
    bne 5f                          // >
    mov x0,x9                       // equal
    bl displayPrime
    add x10,x10,#1                  // increment counter
5:
    add x6,x6,#1                    // increment first indice
    cmp x6,x5                       // maxi ?
    blt 1b                          // and loop

    mov x0,x10                      // number counter
    ldr x1,qAdrsZoneConv
    bl conversion10                 // call décimal conversion
    ldr x0,qAdrszMessCounter
    ldr x1,qAdrsZoneConv            // insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess                // display message

100:                                // standard end of the program
    mov x0, #0                      // return code
    mov x8, #EXIT                   // request to exit program
    svc #0                          // perform the system call
qAdrszCarriageReturn:     .quad szCarriageReturn
qAdrszMessResult:         .quad szMessResult
qAdrszMessCounter:        .quad szMessCounter
qAdrTablePrime:           .quad TablePrime
/******************************************************************/
/*      créate prime array                                       */
/******************************************************************/
createArrayPrime:
    stp x1,lr,[sp,-16]!       // save  registres
    ldr x4,qAdrTablePrime    // address prime table
    mov x0,#1
    str x0,[x4]              // store 1 in array
    mov x0,#2
    str x0,[x4,#8]           // store 2 in array
    mov x0,#3
    str x0,[x4,#16]          // store 3 in array
    mov x5,#3                // prine counter
    mov x7,#5                // first number to test
1:
    mov x6,#1                // indice
2:
    mov x0,x7                // dividende
    ldr x1,[x4,x6,lsl #3]    // load divisor
    udiv x2,x0,x1
    msub x3,x2,x1,x0         // compute remainder
    cmp x3,#0                // null remainder ?
    beq 4f                   // yes -> end loop
    cmp x2,x1                // quotient < divisor
    bge 3f
    str x7,[x4,x5,lsl #3]    // dividende is prime store in array
    add x5,x5,#1             // increment counter
    b 4f                     // and end loop
3:
    add x6,x6,#1             // else increment indice
    cmp x6,x5                // maxi ?
    blt 2b                   // no -> loop
4:
    add x7,x7,#2             // other odd number
    cmp x7,#MAXI             // maxi ?
    blt 1b                   // no -> loop
    mov x0,x5                // return counter
100:
    ldp x1,lr,[sp],16         // restaur des  2 registres
    ret
/******************************************************************/
/*      Display prime table elements                                */
/******************************************************************/
/* x0 contains the prime */
displayPrime:
    stp x1,lr,[sp,-16]!       // save  registres
    ldr x1,qAdrsZoneConv
    bl conversion10           // call décimal conversion
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv      // insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess          // display message
100:
    ldp x1,lr,[sp],16         // restaur des  2 registres
    ret

qAdrsZoneConv:                   .quad sZoneConv

/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"


with Ada.Text_Io;

procedure Additive_Primes is

   Last    : constant := 499;
   Columns : constant := 12;

   type Prime_List is array (2 .. Last) of Boolean;

   function Get_Primes return Prime_List is
      Prime : Prime_List := (others => True);
   begin
      for P in Prime'Range loop
         if Prime (P) then
            for N in 2 .. Positive'Last loop
               exit when N * P not in Prime'Range;
               Prime (N * P) := False;
            end loop;
         end if;
      end loop;
      return Prime;
   end Get_Primes;

   function Sum_Of (N : Natural) return Natural is
      Image : constant String := Natural'Image (N);
      Sum   : Natural := 0;
   begin
      for Char of Image loop
         Sum := Sum + (if Char in '0' .. '9'
                       then Natural'Value ("" & Char)
                       else 0);
      end loop;
      return Sum;
   end Sum_Of;

   package Natural_Io is new Ada.Text_Io.Integer_Io (Natural);
   use Ada.Text_Io, Natural_Io;

   Prime : constant Prime_List := Get_Primes;
   Count : Natural := 0;
begin
   Put_Line ("Additive primes <500:");
   for N in Prime'Range loop
      if Prime (N) and then Prime (Sum_Of (N)) then
         Count := Count + 1;
         Put (N, Width => 5);
         if Count mod Columns = 0 then
            New_Line;
         end if;
      end if;
   end loop;
   New_Line;

   Put ("There are ");
   Put (Count, Width => 2);
   Put (" additive primes.");
   New_Line;
end Additive_Primes;


BEGIN # find additive primes - primes whose digit sum is also prime #
    # sieve the primes to max prime #
    PR read "primes.incl.a68" PR
    []BOOL prime = PRIMESIEVE 499;
    # find the additive primes #
    INT additive count := 0;
    FOR n TO UPB prime DO
        IF prime[ n ] THEN
            # have a prime #
            INT digit sum := 0;
            INT v         := n;
            WHILE v > 0 DO
                digit sum +:= v MOD 10;
                v OVERAB 10
            OD;
            IF prime( digit sum ) THEN
                # the digit sum is prime #
                print( ( " ", whole( n, -3 ) ) );
                IF ( additive count +:= 1 ) MOD 20 = 0 THEN print( ( newline ) ) FI
            FI
        FI
    OD;
    print( ( newline, "Found ", whole( additive count, 0 ), " additive primes below ", whole( UPB prime + 1, 0 ), newline ) )
END


Red []

m: make map! [] 25000

maxx: 0
foreach word  read/lines http://wiki.puzzlers.org/pub/wordlists/unixdict.txt [
sword:  sort copy word ;; sorted characters of word

either find m sword [
    append   m/:sword word
    maxx: max maxx length?  m/:sword
   ] [
      put m sword append copy [] word
    ]
]
foreach v values-of m [ if maxx = length? v [print v] ]


/*REXX program  finds words  with the  largest set of  anagrams  (of the same size).    */
iFID= 'unixdict.txt'                             /*the dictionary input File IDentifier.*/
$=;     !.=;      ww=0;       uw=0;      most=0  /*initialize a bunch of REXX variables.*/
                                                 /* [↓]  read the entire file (by lines)*/
    do  while lines(iFID) \== 0                  /*Got any data?   Then read a record.  */
    parse value  linein(iFID)  with  @ .         /*obtain a word from an input line.    */
    len=length(@);  if len<3  then iterate       /*onesies and twosies words can't win. */
    if \datatype(@, 'M')      then iterate       /*ignore any  non─anagramable words.   */
    uw=uw + 1                                    /*count of the (useable) words in file.*/
    _=sortA(@)                                   /*sort the letters in the word.        */
    !._=!._ @;       #=words(!._)                /*append it to !._;  bump the counter. */
    if #==most  then $=$ _                       /*append the sorted word──► max anagram*/
                else if #>most  then do;   $=_;   most=#;   if len>ww  then ww=len;    end
    end   /*while*/                              /*$ ◄── list of high count anagrams.   */
say '─────────────────────────'    uw     "usable words in the dictionary file: "     iFID
say
     do m=1  for words($);   z=subword($, m, 1)  /*the high count of the anagrams.      */
     say '     '     left(word(!.z, 1),  ww)      '   [anagrams: '      subword(!.z, 2)"]"
     end   /*m*/                                 /*W   is the maximum width of any word.*/
say
say '───── Found'   words($)    "words  (each of which have"    words(!.z)-1  'anagrams).'
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
sortA: arg char 2 xx,@.                          /*get the first letter of arg;  @.=null*/
       @.char=char                               /*no need to concatenate the first char*/
                                                 /*[↓]  sort/put letters alphabetically.*/
                 do length(xx);   parse var xx char 2 xx;    @.[email protected].char || char;    end
                                                 /*reassemble word with sorted letters. */
       return @.a || @.b || @.c || @.d || @.e || @.f||@.g||@.h||@.i||@.j||@.k||@.l||@.m||,
              @.n || @.o || @.p || @.q || @.r || @.s||@.t||@.u||@.v||@.w||@.x||@.y||@.z


DECLARE FUNCTION PDtotal! (n!)
DECLARE SUB PrintAliquotClassifier (K!)
CLS
CONST limite = 10000000

DIM nums(22)
DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, 496
DATA 220, 1184, 12496, 790, 909, 562, 1064, 1488

FOR n = 1 TO UBOUND(nums)
    READ nums(n)
    PRINT "Number"; nums(n); " :";
    PrintAliquotClassifier (nums(n))
NEXT n

PRINT "Program normal end."
END

FUNCTION PDtotal (n)
    total = 0
    FOR y = 2 TO n
        IF (n MOD y) = 0 THEN total = total + (n / y)
    NEXT y
    PDtotal = total
END FUNCTION

SUB PrintAliquotClassifier (K)
    longit = 52: n = K: clase = 0: priorn = 0: inc = 0
    DIM Aseq(longit)

    FOR element = 2 TO longit
        Aseq(element) = PDtotal(n)
        PRINT Aseq(element); " ";
        COLOR 3
        SELECT CASE Aseq(element)
        CASE 0
            PRINT " Terminating": clase = 1: EXIT FOR
        CASE K AND element = 2
            PRINT " Perfect": clase = 2: EXIT FOR
        CASE K AND element = 3
            PRINT " Amicable": clase = 3: EXIT FOR
        CASE K AND element > 3
            PRINT " Sociable": clase = 4: EXIT FOR
        CASE Aseq(element) <> K AND Aseq(element - 1) = Aseq(element)
            PRINT " Aspiring": clase = 5: EXIT FOR
        CASE Aseq(element) <> K AND Aseq(element - 2) = Aseq(element)
            PRINT " Cyclic": clase = 6: EXIT FOR
        END SELECT
        COLOR 7
        n = Aseq(element)
        IF n > priorn THEN priorn = n: inc = inc + 1 ELSE inc = 0: priorn = 0
        IF inc = 11 OR n > limite THEN EXIT FOR
    NEXT element
    IF clase = 0 THEN COLOR 12: PRINT " non-terminating"
    COLOR 7
END SUB


set Object = {}
Object.Hello = "World";
log(Object.Hello);


x: 2
xInfo: info.get 'x

print [
    "address of x:" xInfo\address
    "->" from.hex xInfo\address
]


var num = 12
var pointer = ptr(num) # get pointer

print pointer # print address

@unsafe # bad idea!
pointer.addr = 0xFFFE # set the address


'---get a variable's address
LOCAL x TYPE long
PRINT ADDRESS(x)


'get a variable's address:
DIM x AS INTEGER, y AS LONG
y = VARPTR(x)

'can't set the address, but can access a given memory location... 1 byte at a time
DIM z AS INTEGER
z = PEEK(y)
z = z + (PEEK(y) * 256)


begin % find some additive primes - primes whose digit sum is also prime %
    % sets p( 1 :: n ) to a sieve of primes up to n %
    procedure Eratosthenes ( logical array p( * ) ; integer value n ) ;
    begin
        p( 1 ) := false; p( 2 ) := true;
        for i := 3 step 2 until n do p( i ) := true;
        for i := 4 step 2 until n do p( i ) := false;
        for i := 3 step 2 until truncate( sqrt( n ) ) do begin
            integer ii; ii := i + i;
            if p( i ) then for pr := i * i step ii until n do p( pr ) := false
        end for_i ;
    end Eratosthenes ;
    integer MAX_NUMBER;
    MAX_NUMBER := 500;
    begin
        logical array prime( 1 :: MAX_NUMBER );
        integer       aCount;
        % sieve the primes to MAX_NUMBER %
        Eratosthenes( prime, MAX_NUMBER );
        % find the primes that are additive primes %
        aCount := 0;
        for i := 1 until MAX_NUMBER - 1 do begin
            if prime( i ) then begin
                integer dSum, v;
                v    := i;
                dSum := 0;
                while v > 0 do begin
                    dSum := dSum + v rem 10;
                    v    := v div 10
                end while_v_gt_0 ;
                if prime( dSum ) then begin
                    writeon( i_w := 4, s_w := 0, " ", i );
                    aCount := aCount + 1;
                    if aCount rem 20 = 0 then write()
                end if_prime_dSum
            end if_prime_i
        end for_i ;
        write( i_w := 1, s_w := 0, "Found ", aCount, " additive primes below ", MAX_NUMBER )
    end
end.


on sieveOfEratosthenes(limit)
    script o
        property numberList : {missing value}
    end script

    repeat with n from 2 to limit
        set end of o's numberList to n
    end repeat

    repeat with n from 2 to (limit ^ 0.5) div 1
        if (item n of o's numberList is n) then
            repeat with multiple from n * n to limit by n
                set item multiple of o's numberList to missing value
            end repeat
        end if
    end repeat

    return o's numberList's numbers
end sieveOfEratosthenes

on sumOfDigits(n) -- n assumed to be a positive decimal integer.
    set sum to n mod 10
    set n to n div 10
    repeat until (n = 0)
        set sum to sum + n mod 10
        set n to n div 10
    end repeat

    return sum
end sumOfDigits

on additivePrimes(limit)
    script o
        property primes : sieveOfEratosthenes(limit)
        property additives : {}
    end script

    repeat with p in o's primes
        if (sumOfDigits(p) is in o's primes) then set end of o's additives to p's contents
    end repeat

    return o's additives
end additivePrimes

-- Task code:
tell additivePrimes(499) to return {|additivePrimes<500|:it, numberThereof:count}


# Project : Anagrams

load "stdlib.ring"
fn1 = "unixdict.txt"

fp = fopen(fn1,"r")
str = fread(fp, getFileSize(fp))
fclose(fp)
strlist = str2list(str)
anagram = newlist(len(strlist), 5)
anag = list(len(strlist))
result = list(len(strlist))
for x = 1 to len(result)
     result[x] = 0
next
for x = 1 to len(anag)
     anag[x] = 0
next
for x = 1 to len(anagram)
    for y = 1 to 5
         anagram[x][y] = 0
    next
next

for n = 1 to len(strlist)
     for m = 1 to len(strlist)
          sum = 0
          if len(strlist[n]) = 4 and len(strlist[m]) = 4 and n != m
             for p = 1 to len(strlist[m])
                  temp1 = count(strlist[n], strlist[m][p])
                  temp2 = count(strlist[m], strlist[m][p])
                  if temp1 = temp2
                     sum = sum + 1
                  ok
             next
             if sum = 4
                anag[n] = anag[n] + 1
                if anag[n] < 6 and result[n] = 0 and result[m] = 0
                   anagram[n][anag[n]] = strlist[m]
                   result[m] = 1
                ok
             ok
          ok
    next
    if anag[n] > 0
       result[n] = 1
    ok
next

for n = 1 to len(anagram)
     flag = 0
     for m = 1 to 5
         if anagram[n][m] != 0
            if m = 1
               see strlist[n] +  " "
               flag = 1
            ok
            see anagram[n][m] + " "
         ok
     next
     if flag = 1
        see nl
     ok
next

func getFileSize fp
       c_filestart = 0
       c_fileend = 2
       fseek(fp,0,c_fileend)
       nfilesize = ftell(fp)
       fseek(fp,0,c_filestart)
       return nfilesize

func count(astring,bstring)
       cnt = 0
       while substr(astring,bstring) > 0
               cnt = cnt + 1
               astring = substr(astring,substr(astring,bstring)+len(string(sum)))
       end
       return cnt


require 'open-uri'

anagram = Hash.new {|hash, key| hash[key] = []} # map sorted chars to anagrams

URI.open('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt') do |f|
  words = f.read.split
  for word in words
    anagram[word.split('').sort] << word
  end
end

count = anagram.values.map {|ana| ana.length}.max
anagram.each_value do |ana|
  if ana.length >= count
    p ana
  end
end


#lang racket
(require "proper-divisors.rkt" math/number-theory)

(define SCOPE 20000)

(define P
  (let ((P-v (vector)))
    (λ (n)
      (cond
        [(> n SCOPE)
         (apply + (drop-right (divisors n) 1))]
        [else
         (set! P-v (fold-divisors P-v n 0 +))
         (vector-ref P-v n)]))))

;; initialise P-v
(void (P SCOPE))

(define (aliquot-sequence-class K)
  ;; note that seq is reversed as a list, since we're consing
  (define (inr-asc seq)
    (match seq
      [(list 0 _ ...)
       (values "terminating" seq)]
      [(list (== K) (== K) _ ...)
       (values "perfect" seq)]
      [(list n n _ ...)
       (values (format "aspiring to ~a" n) seq)]
      [(list (== K) ami (== K) _ ...)
       (values (format "amicable with ~a" ami) seq)]
      [(list (== K) cycle ... (== K))
       (values (format "sociable length ~a" (add1 (length cycle))) seq)]
      [(list n cycle ... n _ ...)
       (values (format "cyclic on ~a length ~a" n (add1 (length cycle))) seq)]
      [(list X _ ...)
       #:when (> X 140737488355328)
       (values "non-terminating big number" seq)]
      [(list seq ...)
       #:when (> (length seq) 16)
       (values "non-terminating long sequence" seq)]
      [(list seq1 seq ...) (inr-asc (list* (P seq1) seq1 seq))]))
(inr-asc (list K)))

(define (report-aliquot-sequence-class n)
  (define-values (c s) (aliquot-sequence-class n))
  (printf "~a:\t~a\t~a~%" n c (reverse s)))

(for ((i (in-range 1 10)))
  (report-aliquot-sequence-class i))
(newline)

(for ((i (in-list '(11 12 28 496 220 1184 12496 1264460 790 909 562 1064 1488 15355717786080))))
  (report-aliquot-sequence-class i))


sub propdivsum (\x) {
    my @l = x > 1;
    (2 .. x.sqrt.floor).map: -> \d {
        unless x % d { my \y = x div d; y == d ?? @l.push: d !! @l.append: d,y }
    }
    sum @l;
}

multi quality (0,1)  { 'perfect ' }
multi quality (0,2)  { 'amicable' }
multi quality (0,$n) { "sociable-$n" }
multi quality ($,1)  { 'aspiring' }
multi quality ($,$n) { "cyclic-$n" }

sub aliquotidian ($x) {
    my %seen;
    my @seq = $x, &propdivsum ... *;
    for 0..16 -> $to {
        my $this = @seq[$to] or return "$x\tterminating\t[@seq[^$to]]";
        last if $this > 140737488355328;
        if %seen{$this}:exists {
            my $from = %seen{$this};
            return "$x\t&quality($from, $to-$from)\t[@seq[^$to]]";
        }
        %seen{$this} = $to;
    }
    "$x non-terminating\t[{@seq}]";
}

aliquotidian($_).say for flat
    1..10,
    11, 12, 28, 496, 220, 1184, 12496, 1264460,
    790, 909, 562, 1064, 1488,
    15355717786080;


REM get a variable's address:
y% = ^x%

REM can't set a variable's address, but can access a given memory location (4 bytes):
x% = !y%


unsafe
{
  int i = 5;
  void* address_of_i = &i;
}


data division.
working-storage section.
01 ptr usage pointer.
01 var pic x(64).

procedure division.
set ptr to address of var.


;;; Demonstration of references by swapping two variables using a function rather than a macro
;;; Needs http://paste.lisp.org/display/71952
(defun swap (ref-left ref-right)
  ;; without with-refs we would have to write this:
  ;; (psetf (deref ref-left) (deref ref-right)
  ;;        (deref ref-right) (deref ref-left))
  (with-refs ((l ref-left) (r ref-right))
    (psetf l r r l)))

(defvar *x* 42)
(defvar *y* 0)

(swap (ref *x*) (ref *y*))

;; *y* -> 42
;; *x* -> 0


/* ARM assembly Raspberry PI  */
/*  program additivePrime.s   */

 /* REMARK 1 : this program use routines in a include file
   see task Include a file language arm assembly
   for the routine affichageMess conversion10
   see at end of this program the instruction include */
/* for constantes see task include a file in arm assembly */
/************************************/
/* Constantes                       */
/************************************/
.include "../constantes.inc"

.equ MAXI,      500

/*********************************/
/* Initialized data              */
/*********************************/
.data
szMessResult:        .asciz "Prime  : @ \n"
szMessCounter:      .asciz "Number found : @ \n"
szCarriageReturn:   .asciz "\n"

/*********************************/
/* UnInitialized data            */
/*********************************/
.bss
sZoneConv:                  .skip 24
TablePrime:                 .skip   4 * MAXI
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main
main:                               @ entry of program

    bl createArrayPrime
    mov r5,r0                       @ prime number

    ldr r4,iAdrTablePrime           @ address prime table
    mov r10,#0                      @ init counter
    mov r6,#0                       @ indice
1:
    ldr r2,[r4,r6,lsl #2]           @ load prime
    mov r9,r2                       @ save prime
    mov r7,#0                       @ init digit sum
    mov r1,#10                      @ divisor
2:                                  @ begin loop
    mov r0,r2                       @ dividende
    bl division
    add r7,r7,r3                    @ add digit to digit sum
    cmp r2,#0                       @ quotient null ?
    bne 2b                          @ no -> comppute other digit

    mov r8,#1                       @ indice
4:                                  @ prime search loop
    cmp r8,r5                       @ maxi ?
    bge 5f                          @ yes
    ldr r0,[r4,r8,lsl #2]           @ load prime
    cmp r0,r7                       @ prime >= digit sum ?
    addlt r8,r8,#1                  @ no -> increment indice
    blt 4b                          @ and loop
    bne 5f                          @ >
    mov r0,r9                       @ equal
    bl displayPrime
    add r10,r10,#1                  @ increment counter
5:
    add r6,r6,#1                    @ increment first indice
    cmp r6,r5                       @ maxi ?
    blt 1b                          @ and loop

    mov r0,r10                      @ number counter
    ldr r1,iAdrsZoneConv
    bl conversion10                 @ call décimal conversion
    ldr r0,iAdrszMessCounter
    ldr r1,iAdrsZoneConv            @ insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess                @ display message

100:                                @ standard end of the program
    mov r0, #0                      @ return code
    mov r7, #EXIT                   @ request to exit program
    svc #0                          @ perform the system call
iAdrszCarriageReturn:     .int szCarriageReturn
iAdrszMessResult:         .int szMessResult
iAdrszMessCounter:        .int szMessCounter
iAdrTablePrime:           .int TablePrime
/******************************************************************/
/*      créate prime array                                       */
/******************************************************************/
createArrayPrime:
    push {r1-r7,lr}          @ save registers
    ldr r4,iAdrTablePrime    @ address prime table
    mov r0,#1
    str r0,[r4]              @ store 1 in array
    mov r0,#2
    str r0,[r4,#4]           @ store 2 in array
    mov r0,#3
    str r0,[r4,#8]           @ store 3 in array
    mov r5,#3                @ prine counter
    mov r7,#5                @ first number to test
1:
    mov r6,#1                @ indice
2:
    mov r0,r7                @ dividende
    ldr r1,[r4,r6,lsl #2]    @ load divisor
    bl division
    cmp r3,#0                @ null remainder ?
    beq 3f                   @ yes -> end loop
    cmp r2,r1                @ quotient < divisor
    strlt r7,[r4,r5,lsl #2]  @ dividende is prime store in array
    addlt r5,r5,#1           @ increment counter
    blt 3f                   @ and end loop
    add r6,r6,#1             @ else increment indice
    cmp r6,r5                @ maxi ?
    blt 2b                   @ no -> loop
3:
    add r7,#2                @ other odd number
    cmp r7,#MAXI             @ maxi ?
    blt 1b                   @ no -> loop
    mov r0,r5                @ return counter
100:
    pop {r1-r7,pc}
/******************************************************************/
/*      Display prime table elements                                */
/******************************************************************/
/* r0 contains the prime */
displayPrime:
    push {r1,lr}                    @ save registers
    ldr r1,iAdrsZoneConv
    bl conversion10                 @ call décimal conversion
    ldr r0,iAdrszMessResult
    ldr r1,iAdrsZoneConv            @ insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess                @ display message
100:
    pop {r1,pc}

iAdrsZoneConv:                   .int sZoneConv
/***************************************************/
/*      ROUTINES INCLUDE                           */
/***************************************************/
.include "../affichage.inc"


sqliteconnect #mem, ":memory:"
mem$ = "CREATE TABLE anti(gram,ordr);
CREATE INDEX ord ON anti(ordr)"
#mem execute(mem$)
' read the file
a$ = httpGet$("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")

' break the file words apart
i = 1
while i <> 0
	j	= instr(a$,chr$(10),i+1)
	if j = 0 then exit while
	a1$	= mid$(a$,i,j-i)
	q	= instr(a1$,"'")
	if q > 0 then a1$ = left$(a1$,q) + mid$(a1$,q)
	ln	= len(a1$)
	s$	= a1$

	' Split the characters of the word and sort them
	s = 1
	while	s = 1
		s = 0
		for k = 1 to ln -1
			if mid$(s$,k,1) > mid$(s$,k+1,1) then
				h$	= mid$(s$,k,1)
				h1$	= mid$(s$,k+1,1)
				s$ 	= left$(s$,k-1) + h1$ + h$ + mid$(s$,k+2)
				s	= 1
			end if
		next k
	wend

	mem$	= "INSERT INTO anti VALUES('";a1$;"','";ord$;"')"
	#mem execute(mem$)
	i	= j +1
wend
' find all antigrams
mem$	= "SELECT count(*) as cnt,anti.ordr FROM anti GROUP BY ordr ORDER BY cnt desc"
#mem execute(mem$)
numDups = #mem ROWCOUNT()	'Get the number of rows
dim dups$(numDups)
for i = 1 to numDups
	#row	= #mem #nextrow()
	cnt	= #row cnt()
	if i = 1 then maxCnt = cnt
	if cnt < maxCnt then exit for
	dups$(i) = #row ordr$()
next i

for i = 1 to i -1
	mem$	= "SELECT anti.gram FROM anti
		   WHERE  anti.ordr = '";dups$(i);"'
		   ORDER BY anti.gram"
	#mem execute(mem$)
	rows = #mem ROWCOUNT()	'Get the number of rows

	for ii = 1 to rows
		#row	= #mem #nextrow()
		gram$	= #row gram$()
		print gram$;chr$(9);
	next ii
	print
next i
end


use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead,BufReader};
use std::borrow::ToOwned;

extern crate unicode_segmentation;
use unicode_segmentation::{UnicodeSegmentation};

fn main () {
    let file = BufReader::new(File::open("unixdict.txt").unwrap());
    let mut map = HashMap::new();
    for line in file.lines() {
        let s = line.unwrap();
        //Bytes:      let mut sorted = s.trim().bytes().collect::<Vec<_>>();
        //Codepoints: let mut sorted = s.trim().chars().collect::<Vec<_>>();
        let mut sorted = s.trim().graphemes(true).map(ToOwned::to_owned).collect::<Vec<_>>();
        sorted.sort();

        map.entry(sorted).or_insert_with(Vec::new).push(s);
    }

    if let Some(max_len) = map.values().map(|v| v.len()).max() {
        for anagram in map.values().filter(|v| v.len() == max_len) {
            for word in anagram {
                print!("{} ", word);
            }
            println!();
        }
    }
}


/*REXX program classifies various  positive integers  for  types of  aliquot sequences. */
parse arg low high $L                            /*obtain optional arguments from the CL*/
high= word(high low 10,1);   low= word(low 1,1)  /*obtain the  LOW  and  HIGH  (range). */
if $L=''  then $L=11 12 28 496 220 1184 12496 1264460 790 909 562 1064 1488 15355717786080
numeric digits 100                               /*be able to compute the number:  BIG  */
big= 2**47;                  NTlimit= 16 + 1     /*limits for a non─terminating sequence*/
numeric digits max(9, length(big) )              /*be able to handle big numbers for // */
digs= digits()                                   /*used for align numbers for the output*/
#.= .;        #.0= 0;        #.1= 0              /*#.   are the proper divisor sums.    */
say center('numbers from '      low      " ───► "      high      ' (inclusive)', 153, "═")
          do n=low  to high;    call classify  n /*call a subroutine to classify number.*/
          end   /*n*/                            /* [↑]   process a range of integers.  */
say
say center('first numbers for each classification', 153, "═")
class.= 0                                        /* [↓]  ensure one number of each class*/
          do q=1  until class.sociable\==0       /*the only one that has to be counted. */
          call classify  -q                      /*minus (-) sign indicates don't tell. */
          _= what;  upper _                      /*obtain the class and uppercase it.   */
          class._= class._ + 1                   /*bump counter for this class sequence.*/
          if class._==1  then say right(q, digs)':'      center(what, digs)      $
          end   /*q*/                            /* [↑]  only display the 1st occurrence*/
say                                              /* [↑]  process until all classes found*/
say center('classifications for specific numbers', 153, "═")
          do i=1  for words($L)                  /*$L:  is a list of  "special numbers".*/
          call classify   word($L, i)            /*call a subroutine to classify number.*/
          end   /*i*/                            /* [↑]  process a list of integers.    */
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
classify: parse arg a 1 aa;         a= abs(a)    /*obtain number that's to be classified*/
       if #.a\==.    then s= #.a                 /*Was this number been  summed  before?*/
                     else s= sigma(a)            /*No, then classify number the hard way*/
       #.a= s                                    /*define sum of the  proper divisors.  */
       $= s                                      /*define the start of integer sequence.*/
                     what= 'terminating'         /*assume this kind of classification.  */
       c.=  0                                    /*clear all cyclic sequences (to zero).*/
       c.s= 1                                    /*set the first cyclic sequence.       */
       if $==a  then what= 'perfect'             /*check for a  "perfect"  number.      */
                else do t=1  while s>0           /*loop until sum isn't  0   or   > big.*/
                     m= s                        /*obtain the last number in sequence.  */
                     if #.m==.  then s= sigma(m) /*Not defined? Then sum proper divisors*/
                                else s= #.m      /*use the previously found integer.    */
                     if m==s  then if m>=0   then do;  what= 'aspiring';  leave;   end
                     parse var  $   .  word2  .  /*obtain the 2nd  number in sequence.  */
                     if word2==a             then do;  what= 'amicable';  leave;   end
                     $= $ s                      /*append a sum to the integer sequence.*/
                     if s==a  then if t>3    then do;  what= 'sociable';  leave;   end
                     if c.s   then if m>0    then do;  what= 'cyclic'  ;  leave;   end
                     c.s= 1                      /*assign another possible cyclic number*/
                                                 /* [↓]  Rosetta Code task's limit: >16 */
                     if t>NTlimit     then do;  what= 'non─terminating';  leave;   end
                     if s>big         then do;  what= 'NON─TERMINATING';  leave;   end
                     end   /*t*/                 /* [↑]  only permit within reason.     */
       if aa>0  then say right(a, digs)':'     center(what, digs)     $
       return                                    /* [↑] only display if  AA  is positive*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
sigma: procedure expose #. !.;  parse arg x;   if 11<2  then return 0;        odd= x // 2
       s= 1                                      /* [↓]  use EVEN or ODD integers.   ___*/
            do j=2+odd  by 1+odd  while j*j<x    /*divide by all the integers up to √ X */
            if x//j==0  then  s= s + j +   x % j /*add the two divisors to the sum.     */
            end   /*j*/                          /* [↓]  adjust for square.          ___*/
       if j*j==x  then  s= s + j                 /*Was  X  a square?    If so, add  √ X */
       #.x= s                                    /*memoize division sum for argument  X.*/
       return s                                  /*return      "     "   "      "     " */


MODULE AddressVar;
IMPORT SYSTEM,StdLog;

VAR
	x: INTEGER;

PROCEDURE Do*;
BEGIN
	StdLog.String("ADR(x):> ");StdLog.IntForm(SYSTEM.ADR(x),StdLog.hexadecimal,8,'0',TRUE);StdLog.Ln
END Do;

BEGIN
	x := 10;
END AddressVar.


== Get ==

To get the address of a variable without using the Windows API:

DEF X:INT
DEF pPointer:POINTER
pPointer=X

----

To get the address of a variable using the Windows API Lstrcpy function called in Creative Basic:
(This may give users of another language without a native way to get the address of a variable to work around that problem.)

DEF Win:WINDOW
DEF Close:CHAR
DEF ScreenSizeX,ScreenSizeY,Col:INT

'***Map Function***
DECLARE "Kernel32",Lstrcpy(P1:POINTER,P2:POINTER),INT
'The pointers replace the VB3 variable type of Any.

'Note: This is translated from VB3 or earlier code, and "Ptr" is *not* a Creative Basic pointer.
DEF Ptr:INT
DEF X1:INT
DEF X2:STRING

X1=123

'***Call function***
Ptr=Lstrcpy(X1,X1)

GETSCREENSIZE(ScreenSizeX,ScreenSizeY)

WINDOW Win,0,0,ScreenSizeX,ScreenSizeY,@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"Skel Win",MainHandler

'***Display address***
PRINT Win, "The address of x1 is: " + Hex$(Ptr)
      X2="X2"

WAITUNTIL Close=1

CLOSEWINDOW Win

END

SUB MainHandler

	SELECT @CLASS

	CASE @IDCLOSEWINDOW

	Close=1

	ENDSELECT

RETURN

Note: The Windows Dev Center (http://msdn.microsoft.com/en-us/library/windows/desktop/ms647490%28v=vs.85%29.aspx) says
improper use of the Lstrcpy function may compromise security. A person is advised to see the Windows Dev site before using
the Lstrcopy function.

== Set ==

It appears to the author the closest one can come to setting the address of a variable is to set which bytes will be
used to store a variable in a reserved block of memory:

DEF pMem as POINTER
pMem = NEW(CHAR,1000) : 'Get 1000 bytes to play with
#<STRING>pMem = "Copy a string into memory"
pMem += 100
#<UINT>pMem = 34234: 'Use bytes 100-103 to store a UINT
DELETE pMem


var
	i: integer;
	p: ^integer;
begin
	p := @i;
	writeLn(p^);
end;


/* This code uses a CP/M-specific address to demonstrate fixed locations,
 * so it will very likely only work under CP/M */
proc nonrec main() void:
    /* When declaring a variable, you can let the compiler choose an address */
    word var;

    /* Or you can set the address manually using @, to a fixed address */
    word memtop @ 0x6;     /* CP/M stores the top of memory at 0x0006 */

    /* or to the address of another variable, by naming that variable */
    word var2 @ var;       /* var2 will overlap var */

    /* This works with both automatically and manually placed variables. */
    word memtop2 @ memtop; /* same as "memtop2 @ 0x6" */

    /* Once a variable is declared, you can't change its address at runtime. */

    var := 1234;           /* assign a value to var _and_ var2 */

    /* The address of a variable can be retrieved using the & operator.
     * However, this returns a pointer type, which is distinct from an
     * integer type. To use it as a number, we have to coerce it to an integer
     * first. */
    writeln("var     address=", pretend(&var,word):5,     " value=", var:5);
    writeln("memtop  address=", pretend(&memtop,word):5,  " value=", memtop:5);
    writeln("var2    address=", pretend(&var2,word):5,    " value=", var2:5);
    writeln("memtop2 address=", pretend(&memtop2,word):5, " value=", memtop2:5)
corp


additives: select 2..500 'x -> and? prime? x prime? sum digits x

loop split.every:10 additives 'a ->
    print map a => [pad to :string & 4]

print ["\nFound" size additives "additive primes up to 500"]


# syntax: GAWK -f ADDITIVE_PRIMES.AWK
BEGIN {
    start = 1
    stop = 500
    for (i=start; i<=stop; i++) {
      if (is_prime(i) && is_prime(sum_digits(i))) {
        printf("%4d%1s",i,++count%10?"":"\n")
      }
    }
    printf("\nAdditive primes %d-%d: %d\n",start,stop,count)
    exit(0)
}
function is_prime(x,  i) {
    if (x <= 1) {
      return(0)
    }
    for (i=2; i<=int(sqrt(x)); i++) {
      if (x % i == 0) {
        return(0)
      }
    }
    return(1)
}
function sum_digits(n,  i,sum) {
    for (i=1; i<=length(n); i++) {
      sum += substr(n,i,1)
    }
    return(sum)
}


10 DEFINT A-Z: E=500
20 DIM P(E): P(0)=-1: P(1)=-1
30 FOR I=2 TO SQR(E)
40 IF NOT P(I) THEN FOR J=I*2 TO E STEP I: P(J)=-1: NEXT
50 NEXT
60 FOR I=B TO E: IF P(I) GOTO 100
70 J=I: S=0
80 IF J>0 THEN S=S+J MOD 10: J=J\10: GOTO 80
90 IF NOT P(S) THEN N=N+1: PRINT I,
100 NEXT
110 PRINT: PRINT N;" additive primes found below ";E


val src = io.Source fromURL "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
val vls = src.getLines.toList.groupBy(_.sorted).values
val max = vls.map(_.size).max
vls filter (_.size == max) map (_ mkString " ") mkString "\n"


(import (scheme base)
        (scheme char)
        (scheme file)
        (scheme write)
        (srfi 125)  ; hash tables
        (srfi 132)) ; sorting library

;; read in the words
(define (read-groups)
  (with-input-from-file
    "unixdict.txt"
    (lambda ()
      (let ((groups (hash-table string=?)))
        (do ((line (read-line) (read-line)))
          ((eof-object? line) groups)
          (let* ((key (list->string (list-sort char<? (string->list line))))
                 (val (hash-table-ref/default groups key '())))
            (hash-table-set! groups key (cons line val))))))))

;; extract the longest values from given hash-table of groups
(define (largest-groups groups)
  (define (find-largest grps n sofar)
    (cond ((null? grps)
           sofar)
          ((> (length (car grps)) n)
           (find-largest (cdr grps) (length (car grps)) (list (car grps))))
          ((= (length (car grps)) n)
           (find-largest (cdr grps) n (cons (car grps) sofar)))
          (else
            (find-largest (cdr grps) n sofar))))
  (find-largest (hash-table-values groups) 0 '()))

;; print results
(for-each
  (lambda (group)
    (display "[ ")
    (for-each (lambda (word) (display word) (display " ")) group)
    (display "]\n"))
  (list-sort (lambda (a b) (string<? (car a) (car b)))
             (map (lambda (grp) (list-sort string<? grp))
                  (largest-groups (read-groups)))))


# Project : Aliquot sequence classnifications

see "Rosetta Code - aliquot sequence classnifications" + nl
while true
        see "enter an integer: "
        give k
        k=fabs(floor(number(k)))
        if k=0
           exit
        ok
        printas(k)
end
see "program complete."

func printas(k)
       length=52
       aseq = list(length)
       n=k
       classn=0
       priorn = 0
       inc = 0
       for element=2 to length
            aseq[element]=pdtotal(n)
            see aseq[element] + " " + nl
            if aseq[element]=0
               see " terminating" + nl
               classn=1
               exit
            ok
            if aseq[element]=k and element=2
               see " perfect" + nl
               classn=2
               exit
            ok
            if aseq[element]=k and element=3
               see " amicable" + nl
               classn=3
               exit
            ok
            if aseq[element]=k and element>3
               see " sociable" + nl
               classn=4
               exit
            ok
            if aseq[element]!=k and aseq[element-1]=aseq[element]
               see " aspiring" + nl
               classn=5
               exit
            ok
            if aseq[element]!=k and element>2 and aseq[element-2]= aseq[element]
               see " cyclic" + nl
               classn=6
              exit
            ok
            n=aseq[element]
            if n>priorn
               priorn=n
               inc=inc+1
            but n<=priorn
                  inc=0
                  priorn=0
            ok
            if inc=11 or n>30000000
               exit
            ok
       next
       if classn=0
          see " non-terminating" + nl
       ok

func pdtotal(n)
       pdtotal = 0
       for y=2 to n
           if (n % y)=0
               pdtotal=pdtotal+(n/y)
           ok
       next
       return pdtotal


def aliquot(n, maxlen=16, maxterm=2**47)
  return "terminating", [0] if n == 0
  s = []
  while (s << n).size <= maxlen and n < maxterm
    n = n.proper_divisors.inject(0, :+)
    if s.include?(n)
      case n
      when s[0]
        case s.size
        when 1   then   return "perfect", s
        when 2   then   return "amicable", s
        else            return "sociable of length #{s.size}", s
        end
      when s[-1] then   return "aspiring", s
      else              return "cyclic back to #{n}", s
      end
    elsif n == 0 then   return "terminating", s << 0
    end
  end
  return "non-terminating", s
end

for n in 1..10
  puts "%20s: %p" % aliquot(n)
end
puts
for n in [11, 12, 28, 496, 220, 1184,  12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080]
  puts "%20s: %p" % aliquot(n)
end


variable foo
foo .  \ some large number, an address
8 foo !
foo @ .  \ 8


program test_loc
  implicit none

  integer :: i
  real    :: r

  i = loc(r)
  print *, i
end program


' FB 1.05.0 Win64
Dim a As Integer = 3
Dim p As Integer Ptr = @a
Print a, p


window 1

short i = 575
ptr j

j = @i

printf @"Address of i = %ld",j
print @"Value of i = ";peek word(j)

HandleEvents


print "Prime", "Digit Sum"
for i = 2 to 499
    if isprime(i) then
        s = digSum(i)
        if isPrime(s) then print i, s
    end if
next i
end

function isPrime(v)
    if v < 2 then return False
    if v mod 2 = 0 then return v = 2
    if v mod 3 = 0 then return v = 3
    d = 5
    while d * d <= v
        if v mod d = 0 then return False else d += 2
    end while
    return True
end function

function digsum(n)
    s = 0
    while n
        s += n mod 10
        n /= 10
    end while
    return s
end function


get "libhdr"
manifest $( limit = 500 $)

let dsum(n) =
    n=0 -> 0,
    dsum(n/10) + n rem 10

let sieve(prime, n) be
$(  0!prime := false
    1!prime := false
    for i=2 to n do i!prime := true
    for i=2 to n/2
        if i!prime
        $(  let j=i+i
            while j<=n
            $(  j!prime := false
                j := j+i
            $)
        $)
$)

let additive(prime, n) = n!prime & dsum(n)!prime

let start() be
$(  let prime = vec limit
    let num = 0
    sieve(prime, limit)
    for i=2 to limit
        if additive(prime,i)
        $(  writed(i,5)
            num := num + 1
            if num rem 10 = 0 then wrch('*N')
        $)
    writef("*N*NFound %N additive primes < %N.*N", num, limit)
$)


#include <stdbool.h>
#include <stdio.h>
#include <string.h>

void memoizeIsPrime( bool * result, const int N )
{
    result[2] = true;
    result[3] = true;
    int prime[N];
    prime[0] = 3;
    int end = 1;
    for (int n = 5; n < N; n += 2)
    {
        bool n_is_prime = true;
        for (int i = 0; i < end; ++i)
        {
            const int PRIME = prime[i];
            if (n % PRIME == 0)
            {
                n_is_prime = false;
                break;
            }
            if (PRIME * PRIME > n)
            {
                break;
            }
        }
        if (n_is_prime)
        {
            prime[end++] = n;
            result[n] = true;
        }
    }
}/* memoizeIsPrime */

int sumOfDecimalDigits( int n )
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}/* sumOfDecimalDigits */

int main( void )
{
    const int N = 500;

    printf( "Rosetta Code: additive primes less than %d:\n", N );

    bool is_prime[N];
    memset( is_prime, 0, sizeof(is_prime) );
    memoizeIsPrime( is_prime, N );

    printf( "   2" );
    int count = 1;
    for (int i = 3; i < N; i += 2)
    {
        if (is_prime[i] && is_prime[sumOfDecimalDigits( i )])
        {
            printf( "%4d", i );
            ++count;
            if ((count % 10) == 0)
            {
                printf( "\n" );
            }
        }
    }
    printf( "\nThose were %d additive primes.\n", count );
    return 0;
}/* main */


$ include "seed7_05.s7i";
  include "gethttp.s7i";
  include "strifile.s7i";

const type: anagramHash is hash [string] array string;

const func string: sort (in string: stri) is func
  result
    var string: sortedStri is "";
  local
    var integer: i is 0;
    var integer: j is 0;
    var char: ch is ' ';
  begin
    sortedStri := stri;
    for i range 1 to length(sortedStri) do
      for j range succ(i) to length(sortedStri) do
        if sortedStri[i] > sortedStri[j] then
          ch := sortedStri[i];
          sortedStri @:= [i] sortedStri[j];
          sortedStri @:= [j] ch;
        end if;
      end for;
    end for;
  end func;

const proc: main is func
  local
    var file: dictFile is STD_NULL;
    var string: word is "";
    var string: sortedLetters is "";
    var anagramHash: anagrams is anagramHash.value;
    var integer: length is 0;
    var integer: maxLength is 0;
  begin
    dictFile := openStrifile(getHttp("wiki.puzzlers.org/pub/wordlists/unixdict.txt"));
    while hasNext(dictFile) do
      readln(dictFile, word);
      sortedLetters := sort(word);
      if sortedLetters in anagrams then
        anagrams[sortedLetters] &:= word;
      else
        anagrams @:= [sortedLetters] [] (word);
      end if;
      length := length(anagrams[sortedLetters]);
      if length > maxLength then
        maxLength := length;
      end if;
    end while;
    close(dictFile);
    for sortedLetters range sort(keys(anagrams)) do
      if length(anagrams[sortedLetters]) = maxLength then
        writeln(join(anagrams[sortedLetters], ", "));
      end if;
    end for;
  end func;


h := open('unixdict.txt', "r");
anagrams := {};
while not eof(h) loop
  geta(h, word);
  if word = om or word = "" then
    continue;
  end if;
  sorted := insertion_sort(word);
  anagrams{sorted} with:= word;
end loop;

max_size := 0;
max_words := {};
for words = anagrams{sorted} loop
  size := #words;
  if size > max_size then
    max_size := size;
    max_words := {words};
  elseif size = max_size then
    max_words with:= words;
  end if;
end loop;

for w in max_words loop
  print(w);
end loop;

-- GNU SETL has no built-in sort()
procedure insertion_sort(A);
  for i in [2..#A] loop
    v := A(i);
    j := i-1;
    while j >= 1 and A(j) > v loop
      A(j+1) := A(j);
      j := j - 1;
    end loop;
    A(j+1) := v;
 end loop;
 return A;
end procedure;


#[derive(Debug)]
enum AliquotType { Terminating, Perfect, Amicable, Sociable, Aspiring, Cyclic, NonTerminating }

fn classify_aliquot(num: i64) -> (AliquotType, Vec<i64>) {
    let limit = 1i64 << 47; //140737488355328
    let mut terms = Some(num).into_iter().collect::<Vec<_>>();
    for i in 0..16 {
        let n = terms[i];
        let divsum = (1..(n + 1) / 2 + 1).filter(|&x| n % x == 0 && n != x).fold(0, |sum, x| sum + x);
        let classification = if divsum == 0 {
            Some(AliquotType::Terminating)
        }
        else if divsum > limit {
            Some(AliquotType::NonTerminating)
        }
        else if let Some(prev_idx) = terms.iter().position(|&x| x == divsum) {
            let cycle_len = terms.len() - prev_idx;
            Some(if prev_idx == 0 {
                match cycle_len {
                    1 => AliquotType::Perfect,
                    2 => AliquotType::Amicable,
                    _ => AliquotType::Sociable
                }
            }
            else {
                if cycle_len == 1 {AliquotType::Aspiring} else {AliquotType::Cyclic}
            })
        }
        else {
            None
        };
        terms.push(divsum);
        if let Some(result) = classification {
            return (result, terms);
        }
    }
    (AliquotType::NonTerminating, terms)
}

fn main() {
    let nums = [1i64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, 496, 220, 1184, 12496, 1264460, 790, 909, 562, 1064, 1488/*, 15355717786080*/];
    for num in &nums {
        println!("{} {:?}", num, classify_aliquot(*num));
    }
}


def createAliquotSeq(n: Long, step: Int, list: List[Long]): (String, List[Long]) = {
    val sum = properDivisors(n).sum
    if (sum == 0) ("terminate", list ::: List(sum))
    else if (step >= 16 || sum > 140737488355328L) ("non-term", list)
    else {
        list.indexOf(sum) match {
            case -1 => createAliquotSeq(sum, step + 1, list ::: List(sum))
            case 0 => if (step == 0) ("perfect", list ::: List(sum))
                else if (step == 1) ("amicable", list ::: List(sum))
                else ("sociable-" + (step + 1), list ::: List(sum))
            case index => if (step == index) ("aspiring", list ::: List(sum))
                else ("cyclic-" + (step - index + 1), list ::: List(sum))
        }
    }
}
val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, 496, 220, 1184,
    12496, 1264460, 790, 909, 562, 1064, 1488, 15355717786080L)
val result = numbers.map(i => createAliquotSeq(i, 0, List(i)))

result foreach { v => println(f"${v._2.head}%14d ${v._1}%10s [${v._2 mkString " "}]" ) }


package main

import (
	"fmt"
	"unsafe"
)

func main() {
	myVar := 3.14
	myPointer := &myVar
	fmt.Println("Address:", myPointer, &myVar)
	fmt.Printf("Address: %p %p\n", myPointer, &myVar)

	var addr64 int64
	var addr32 int32
	ptr := unsafe.Pointer(myPointer)
	if unsafe.Sizeof(ptr) <= unsafe.Sizeof(addr64) {
		addr64 = int64(uintptr(ptr))
		fmt.Printf("Pointer stored in   int64: %#016x\n", addr64)
	}
	if unsafe.Sizeof(ptr) <= unsafe.Sizeof(addr32) {
		// Only runs on architectures where a pointer is <= 32 bits
		addr32 = int32(uintptr(ptr))
		fmt.Printf("Pointer stored in   int32: %#08x\n", addr32)
	}
	addr := uintptr(ptr)
	fmt.Printf("Pointer stored in uintptr: %#08x\n", addr)

	fmt.Println("value as float:", myVar)
	i := (*int32)(unsafe.Pointer(&myVar))
	fmt.Printf("value as int32: %#08x\n", *i)
}


== Get ==

There are at least three ways to get the address of a variable in IWBASIC. The first is to use the address of operator:

DEF X:INT
PRINT &X
'This will print in the console window (after OPENCONSOLE is issued.)
'To Print in an open window the appropriate Window variable is specified, e.g., PRINT Win,&X.

The second is to use a pointer:

DEF X:INT
DEF pPointer:POINTER
pPointer=X

The third is to use the Windows API function Lstrcpy. That is done in the same way as the Creative Basic example;
however, the function would be declared as follows: DECLARE IMPORT,Lstrcpy(P1:POINTER,P2:POINTER),INT.

== Set ==

It appears to the author that the closest one can come to being able to assign an address to a variable is to set
which bytes will be used to store a variable in a block of reserved memory:

DEF pMem as POINTER
pMem = NEW(CHAR,1000) : 'Get 1000 bytes to play with
#<STRING>pMem = "Copy a string into memory"
pMem += 100
#<UINT>pMem = 34234: 'Use bytes 100-103 to store a UINT
DELETE pMem


   var      =: 52                NB.  Any variable (including data, functions, operators etc)
   var_addr =: 15!:6<'var'       NB.  Get address
   new_var  =: 15!:7 var_addr    NB.  Set address