473,848 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling J from Python

It is quite easy to call J from Python


Feb 5 '07
50 2928
George Sakkis <ge***********@ gmail.comwrote:
On Feb 9, 9:20 pm, bearophileH...@ lycos.com wrote:
This is a bit simpler, but probably there are simpler solutions using
modular arithmetic:

l = [1]
for _ in range(15):
print ''.join(" *"[x] for x in l)
l = [1] + [l[i+1]^l[i] for i in range(len(l)-1)] + [1]


Here's another one, adapted from the example (in Java) in Wikipedia's
entry (http://en.wikipedia.org/wiki/Sierpinski_triangle):

for x in xrange(N,0,-1):
print ''.join('* '[x&y!=0] for y in xrange(N+1-x))
This is my solution after a few minutes thought.

It uses a different algorithm for generating the triangle. If python
could output binary numbers it would be more elegant...
>>n = 1
for i in range(16):
.... print ("%X" % n).replace('0', ' ').replace('1', '*')
.... n = n ^ (n << 4)
* *
* *
** **
* * * *
* *
** **
* * * *
**** ****
* * * *
** ** ** **
* * * * * * * *
*************** *
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Feb 10 '07 #51

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Bill Orcutt | last post by:
Having seen the number of lost souls asking questions about embedding Python in the archives of this group, I hesitate to add myself to their number, but I've hit a problem I can't quite get my head around. I have a simple C program that embeds a python interpreter to execute python commands and return stdout, and to a point everything works as intended. The problem that each command seems to be executed in its own context and knows...
by: Natsu Mizutani | last post by:
Hello, I'm trying to wrap a c++ library using MPI inside with boost.python (or SWIG). I managed to find that calling `MPI::Init()` embeded in a c++ funtion would not work. So, I decided to use `pyMPI`. To avoid overhead of pickling and unpickling while calling `mpi.send` in Python, I'd rather call c++ functions `MPI::Isend()` etc. embeded in a c++ function.
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
by: Kamilche | last post by:
What a debug nightmare! I just spent HOURS running my script through the debugger, sprinkling in log statements, and the like, tracking down my problem. I called a function without the ending parentheses. I sure do WISH Python would trap it when I try to do the following: MyFunc instead of:
by: Stephen Kellett | last post by:
Hello everyone, I'm trying to do something in C calling Python and its failing. I'd be grateful if you could take a look and hopefully you have an answer. What I'm trying to do is determine the address of the "collect" function in the "gc" module. I want to do this so that we can determine when a garbage collection happens, regardless of how it is triggered (explicitly by a user call, or implicitly by the behaviour of the program...
by: Gerald Klix | last post by:
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss something? Cya, Gerald -----Ursprüngliche Nachricht----- Von: python-list-bounces+gerald.klix=klix.ch@python.org Im Auftrag von
by: Finger.Octopus | last post by:
Hello, I have been trying to call the super constructor from my derived class but its not working as expected. See the code: class HTMLMain: def __init__(self): self.text = "<HTML><BODY>"; print(self.text); def __del__(self): self.text = "</BODY></HTML>"; print(self.text);
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved external symbol error. Whatever i try its giving more and more errrors...so is it possible to merge 2...
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've compiled a DLL of the Python source code using the pythoncode VC++ project in the PCbuild folder of the source download and this works 100% without any warnings etc. I've done this in Debug and Release mode without any problems.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.