Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/examples/io.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


( Copyright 1995,2003 - HanSoft & Partners - 4th I/O demonstration )

[needs lib/enter.4th]

: select_base decimal ." Select base : " enter dup base ! ;
: get_number ." Input number: " enter ;

: show_base                            ( shows base without affecting base )
  dup
  decimal
  [char] [ emit 0 .r [char] ] emit space
  base !
;

: show_number                          ( shows conversion output )
  rot
  show_base
  swap dup . ." => " swap
  show_base .
;

: convert                              ( converts a number )
  cr
  select_base
  get_number
  select_base
  cr
  show_number
  cr
;

convert cr

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.